asionwu 发表于 2010-5-10 11:17:17

Delphi 代码如何转换成 Au3(GetSfcFiles API )[已解决]

本帖最后由 asionwu 于 2010-5-10 16:28 编辑

这个是 Delphi 调用GetSfcFiles API 的代码program GetSfcFiles_Sample;
{$APPTYPE CONSOLE}
uses
Windows;


type
TSfcList = record
    wcsFileNameInDllCache: PWideChar; // Name of the file in DllCache
    wcsFilePath: PWideChar; // Path of the protected file
    wcsWhatEverInfFile: PWideChar; // Name of some INF file ... unknown meaning
end;
TSfcListArray = array of TSfcList;
PSfcListArray = ^TSfcListArray;

function SfcGetFiles(
var lpNamelist: PSfcListArray;
var lpNumEntries: DWORD
): DWORD; stdcall; external 'sfcfiles.dll';
(* Call and then iterate through the array with wide strings NumEntries times. *)

var
namelist:PSfcListArray;
i, num:DWORD;
begin
{ This crappy example simply dumps all SFC protected files to the console }
if SfcGetFiles(namelist, num)=ERROR_SUCCESS then
    for i:=0 to num-1 do
      Writeln(String(namelist^.wcsFilePath));
end.请熟悉这方面的高手帮忙一下,谢谢

pppp0831 发表于 2010-5-10 13:18:09

Const $DllFileName=@ScriptDir & "\sfcfiles.dll"
Global $hWnd_sfclist,$filecount
$stru_list=_GetsTru_sfclist()
$hWnd_sfclist=DllStructGetPtr($stru_list)
$result = DllCall($DllFileName,"DWORD","sfcGetfiles","HANDLE",$hWnd_sfclist,"int",$filecount)
For $i = 0to $filecount -1Step 1
        $filepath=DllStructGetData($stru_list,"wcsFilePath")
        write($filepath)
Next

Func _GetsTru_sfclist()
        Local $ListStr
        $ListStr="wcsFileNameInDllCache;wcsFilePath;wcsWhatEverInfFile"
        Return DllStructCreate($ListStr)
EndFunc

pppp0831 发表于 2010-5-10 13:37:06

修正下
DllCall($DllFileName,"DWORD","sfcGetfiles","Ptr",$hWnd_sfclist,"int",$filecount)

Hen5ei 发表于 2010-5-10 14:58:27

看不懂噶。。。看来楼上确实高手

skyer158 发表于 2010-6-6 23:40:21

无法看懂哦,看来得加紧练功啊

haijie1223 发表于 2022-3-31 18:41:12

目测2楼的代码并不正确,这个api的调用有点不太友好。以前玩xp封装的时候,也曾为这个api苦恼了一段时间。
页: [1]
查看完整版本: Delphi 代码如何转换成 Au3(GetSfcFiles API )[已解决]