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