What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » ReadFile API

ReadFile API
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
O.P. ReadFile API
code:
var GENERIC_READ = 0x80000000;
var FILE_BEGIN = 0;
var FILE_SHARE_READ = 1;
var OPEN_EXISTING = 3;

function OnEvent_Initialize(MessengerStart){
    var hOrgFile = Interop.Call('kernel32', 'CreateFileW', 'c:\\test.txt', GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
    var nSize = Interop.Call('kernel32', 'GetFileSize', hOrgFile, 0);
    Debug.Trace('nSize: '+nSize);
    var sText = Interop.Allocate(nSize+1);
    var lRet = Interop.Allocate(4);
    Interop.Call('kernel32', 'ReadFile', hOrgFile, sText, nSize, lRet.DataPtr, 0);
    Debug.Trace(lRet.ReadDWORD(0));
    Debug.Trace(sText.ReadString(0));
    Interop.Call('kernel32', 'CloseHandle', hOrgFile);
}

sText.ReadDWORD(0) is null and lRet.ReadDWORD(0) is 0.

Not sure what I am doing wrong.

ReadFile API msdn

This post was edited on 09-11-2006 at 08:55 PM by matty.
09-11-2006 08:52 PM
Profile E-Mail PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: ReadFile API
Confirmed, I was testing this with Matty...WriteFile doesn't seem to work either, by the way.
09-11-2006 09:04 PM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: ReadFile API
I had a problem with this ages ago aswell http://shoutbox.menthix.net/showthread.php?tid=58419
[Image: dt2.0v2.png]      Happy Birthday, WDZ
09-11-2006 11:07 PM
Profile PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: ReadFile API
Isn't there an ActiveX control you can use for file I/O instead of the raw API? I'm sure I've seen one before.

Edit: Like below.

This post was edited on 09-11-2006 at 11:32 PM by RaceProUK.
[Image: spartaafk.png]
09-11-2006 11:18 PM
Profile PM Web Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
37 / Male / –
Joined: May 2004
Status: Away
RE: ReadFile API
Can't you just use the Scripting.FileSystemObject?

http://mpwiki.net/Text_Files

It's a lot easier and works.

Unless I'm missing some obvious reason you had to use that.
09-11-2006 11:20 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
O.P. RE: ReadFile API
Screenshot Sender 4 already uses FileSystemObject but for some very odd reason it gives errors when initializing for some people however it is properly installed because I can call it on that PC through a normal EXE. So instead of having ActiveX dependencies why not make it pure API.

quote:
Originally posted by alexp2_ad
Can't you just use the Scripting.FileSystemObject?

http://mpwiki.net/Text_Files

It's a lot easier and works.

Unless I'm missing some obvious reason you had to use that.

And I don't mean to be rude, but obviously if I am going as far as using the Windows API I would know about simple scripting objects.

This post was edited on 09-12-2006 at 06:03 AM by matty.
09-12-2006 01:01 AM
Profile E-Mail PM Find Quote Report
Patchou
Messenger Plus! Creator
*****

Avatar

Posts: 8607
Reputation: 201
43 / Male / Flag
Joined: Apr 2002
RE: ReadFile API
Thanks for the report, I can't believe those two bugs were not fixed before now:

Interop.GetLastError() now actually works
Values from 0x80000000 to 0xFFFFFFFF can now be passed safely to Interop.Call

For those of you interested in the details: I just foudn out that values above 0x80000000 are always sent by JScript as "double" (8bit) instead of "integer" (probably because unsigned values arent generally safe in scripting environement).
[Image: signature2.gif]
09-12-2006 05:46 AM
Profile PM Web Find Quote Report
alexp2_ad
Scripting Contest Winner
****

Avatar
Who love the chocolate?

Posts: 691
Reputation: 26
37 / Male / –
Joined: May 2004
Status: Away
RE: RE: ReadFile API
quote:
Originally posted by Matty
Screenshot Sender 4 already uses FileSystemObject but for some very odd reason it gives errors when initializing for some people however it is properly installed because I can call it on that PC through a normal EXE. So instead of having ActiveX dependencies why not make it pure API.

And I don't mean to be rude, but obviously if I am going as far as using the Windows API I would know about simple scripting objects.

Lol, why to people say "I don't mean to be rude but" then be rude. :P

I just wanted to know why you couldn't use the fso so I could learn more. :^)
09-12-2006 09:18 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On