本帖最后由 pusofalse 于 2010-8-16 13:06 编辑
同是只用一句DllStructCreate("char[2048]")就可以了。在实际的API调用中,可以如下:$tBuffer = DllStructCreate("char[2048];dword")
$pBuffer = DllStructGetPtr($tBuffer)
$pBytesRead = DllStructGetPtr($tBuffer, 2)
$iResult = DllCall("Kernel32.dll", "bool", "ReadFile", "handle", $hFileOpened, "ptr", $pBuffer, "dword", 2048, "ptr", $pBytesRead, "ptr", 0)
MsgBox(0, DllStructGetData($tBuffer, 2), DllStructGetData($tBuffer, 1))
或者不必创建缓存区,直接调用如下:$iResult = DllCall("Kernel32.dll", "bool", "ReadFile", "handle", $hFileOpened, "str", "", "dword", 2048, "dword*", 0, "ptr", 0)
MsgBox(0, $iResult[4], $iResult[2])
|