我想SHFileOperation使用代码注入来调用。我的代码在调用MessageBoxfrom等简单函数时工作正常user32.dll,但在调用ShFileOperationfrom时不会shell32.dll。
我将发布我认为有问题的代码部分。我知道问题出在结构实现中。
这是 RemoteInfo 值的图像:
http://www.freeimagehosting.net/uploads/219d79fc30.jpg
//结构
类型
LPSHFILEOPSTRUCT = ^SHFILEOPSTRUCT;
SHFILEOPSTRUCT = 打包记录
Wnd:HWND;
wFunc:UINT;
p来自:PAnsiChar;
pTo:PAnsiChar;
fFlags:FILEOP_FLAGS;
fAnyOperationsAborted: BOOL;
hNameMappings:指针;
lpszProgressTitle:PAnsiChar;
结尾;
//远程信息
类型
TRemoteInfo = 记录
LoadLibrary:函数(lpLibFileName:PChar):HMODULE;标准调用;
GetProcAddress:函数(hModule:HMODULE;
lpProcName:LPCSTR):FARPROC;标准调用;
shf: SHFILEOPSTRUCT; ;
Kernel32:Char数组[0..20];
shell32: 数组 [0..20] 的字符;
SHFileOperationA: 数组[0..20] 的字符;
Fromlpbuff:char数组[0..20];//源路径
Tolpbuff:Char的array[0..20];//Des路径
结尾;
//初始化
……
ZeroMemory(@RemoteInfo, SizeOf(RemoteInfo));
远程信息.shf.Wnd := 0;
RemoteInfo.shf.wFunc := FO_COPY;
RemoteInfo.shf.pFrom := @remoteInfo.Fromlpbuff;
RemoteInfo.shf.pto := @remoteInfo.tolpbuff;
lstrcpy(RemoteInfo.shf.pFrom, 'e:\1.jpg' + #0#0);
lstrcpy(RemoteInfo.shf.pto, 'f:\1.jpg' + #0#0);
RemoteInfo.shf.fFlags := FOF_ALLOWUNDO;
RemoteInfo.shf.fAnyOperationsAborted := false;
……