InternetOpenUrlW - what am I doing wrong? |
Author: |
Message: |
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
O.P. InternetOpenUrlW - what am I doing wrong?
code: var INTERNET_FLAG_RELOAD = 2147483648;
var INTERNET_OPEN_TYPE_DIRECT = 1;
var INTERNET_OPEN_TYPE_PROXY = 3;
var Version = 1;
function OnEvent_Initialize(MessengerStart){
CheckUpdate('http://mattyg.ca/test/', 'AutoUpdateTest');
}
function CheckUpdate(sUrl, sFile){
var hOpen = Interop.Allocate(4);
var hFile = Interop.Allocate(4);
var sBuffer = Interop.Allocate(2*(1000)+2);
var lBuffer = Interop.Allocate(4);
lBuffer.WriteDWORD(0, 1000);
var lRet;
hOpen.WriteDWORD(0, Interop.Call('wininet', 'InternetOpenW', 'ScreenshotSender4Updater', INTERNET_OPEN_TYPE_DIRECT, '', '', 0));
hFile.WriteDWORD(0, Interop.Call('wininet', 'InternetOpenUrlW', hOpen.ReadDWORD(0), sUrl+sFile+'.version', '', 0, INTERNET_FLAG_RELOAD, 0));
Interop.Call('wininet', 'InternetReadFile', hFile.ReadDWORD(0), sBuffer.DataPtr, lBuffer.ReadDWORD(0), lRet);
Interop.Call('wininet', 'InternetCloseHandle', hFile.ReadDWORD(0));
Interop.Call('wininet', 'InternetCloseHandle', hOpen.ReadDWORD(0));
Debug.Trace(sBuffer.ReadString(0));
}
Ya so what am I doing wrong? I tried passing lBuffer as a normal var (didn't work), tried passing 1000 didn't work. sBuffer.ReadString(0) is null so I am not sure what is wrong.
|
|
07-01-2006 03:07 AM |
|
|
ShawnZ
Veteran Member
Posts: 3146 Reputation: 43
32 / /
Joined: Jan 2003
|
RE: InternetOpenUrlW - what am I doing wrong?
off topic, but why not use xmlhttp?
Spoiler: the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
the game.
|
|
07-01-2006 05:29 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
O.P. RE: InternetOpenUrlW - what am I doing wrong?
quote: Originally posted by ShawnZ
off topic, but why not use xmlhttp?
It was working for me then all of a sudden without changing any code it stopped returning the value but instead a null string.
|
|
07-01-2006 05:31 AM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: InternetOpenUrlW - what am I doing wrong?
you use way too many datablocs where theyre not needed, and then dont use one where it is needed (lRet)
working code:
code: var INTERNET_FLAG_RELOAD = 2147483648;
var INTERNET_OPEN_TYPE_DIRECT = 1;
var INTERNET_OPEN_TYPE_PROXY = 3;
var Version = 1;
function OnEvent_Initialize(MessengerStart){
CheckUpdate('http://mattyg.ca/test/', 'AutoUpdateTest');
}
function CheckUpdate(sUrl, sFile){
var sBuffer = Interop.Allocate((255+1) * 2);
var lRet = Interop.Allocate(4);
hOpen = Interop.Call('wininet', 'InternetOpenW', 'ScreenshotSender4Updater', INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0);
hFile = Interop.Call('wininet', 'InternetOpenUrlW', hOpen, sUrl+sFile+'.version', '', 0, INTERNET_FLAG_RELOAD, 0);
test = Interop.Call('wininet', 'InternetReadFile', hFile, sBuffer, 255, lRet);
Interop.Call('wininet', 'InternetCloseHandle', hFile);
Interop.Call('wininet', 'InternetCloseHandle', hOpen);
Debug.Trace(sBuffer.ReadString(0));
}
|
|
07-01-2006 07:27 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
O.P. RE: InternetOpenUrlW - what am I doing wrong?
quote: Originally posted by Eljay
you use way too many datablocs where theyre not needed, and then dont use one where it is needed (lRet)
<3 lj
Thanks ya I realized that I only needed the databloc for the hOpen and hFile if they are being passed as a param that recieves a return value.
|
|
07-01-2006 01:41 PM |
|
|
|
|