Shoutbox

InternetOpenUrlW - what am I doing wrong? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: InternetOpenUrlW - what am I doing wrong? (/showthread.php?tid=62201)

InternetOpenUrlW - what am I doing wrong? by matty on 07-01-2006 at 03:07 AM

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.
RE: InternetOpenUrlW - what am I doing wrong? by ShawnZ on 07-01-2006 at 05:29 AM

off topic, but why not use xmlhttp?


RE: InternetOpenUrlW - what am I doing wrong? by matty on 07-01-2006 at 05:31 AM

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.
RE: InternetOpenUrlW - what am I doing wrong? by Eljay on 07-01-2006 at 07:27 AM

you use way too many datablocs where theyre not needed, and then dont use one where it is needed (lRet) :P

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));
}

RE: InternetOpenUrlW - what am I doing wrong? by matty on 07-01-2006 at 01:41 PM

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) :P

<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.