如题, Struct如下:typedef struct _AdvancedStruct
{
int (WINAPI *AddedFile)(char *lpFileName);
int (WINAPI *AddedKey)(HKEY hKeyRoot,char *lpPath);
int (WINAPI *AddedValue)(HKEY hKeyRoot,char *lpPath,char *
lpValueName);
int (WINAPI *AddShared)(char *lpSharedFile);
int (WINAPI *BackupFile)(char *lpFileName);
int (WINAPI *CreateDirectory)(char *lpDirectory);
char * lpCommandLine;
HBITMAP hbmDialog;
BOOL bSilent;
DWORD *lpdwFlags;
char *(WINAPI *GetVariableString)(char *lpVariable);
int (WINAPI *GetVariableInt)(char *lpVariable);
int (WINAPI *SetVariableString)(char *lpVariable,char *
lpValue);
int (WINAPI *SetVariableInt)(char *lpVariable,int iValue);
} AdvancedStruct;
{
int (WINAPI *AddedFile)(char *lpFileName);
int (WINAPI *AddedKey)(HKEY hKeyRoot,char *lpPath);
int (WINAPI *AddedValue)(HKEY hKeyRoot,char *lpPath,char *
lpValueName);
int (WINAPI *AddShared)(char *lpSharedFile);
int (WINAPI *BackupFile)(char *lpFileName);
int (WINAPI *CreateDirectory)(char *lpDirectory);
char * lpCommandLine;
HBITMAP hbmDialog;
BOOL bSilent;
DWORD *lpdwFlags;
char *(WINAPI *GetVariableString)(char *lpVariable);
int (WINAPI *GetVariableInt)(char *lpVariable);
int (WINAPI *SetVariableString)(char *lpVariable,char *
lpValue);
int (WINAPI *SetVariableInt)(char *lpVariable,int iValue);
} AdvancedStruct;
struct _AdvancedStruct = Record
lpCommandLine : Char
.
.
.end;
type
struct _AdvancedStruct = class
public
然后把里面的函数写进去,会不会转函数呀?
例如 int (WINAPI *AddedFile)(char *lpFileName);
应该转为function AddedFile (lpFileName : pchar) : pointer;stdcall;
stdcall是参数调用顺序,是从右到左调用,还可以用pascal,是从左到右调用参数
*AddedFile返回的是地址,如果需要,就另设一个变量,variants : integer;
variants = ^AddedFile();就行了,不知道这样说你明不明白?
我的表达不好,请见谅!
但我还不是很明白(基础不好啊),我主要是想把下面的代码转成delphi的typedef struct _AdvancedStruct
{
int (WINAPI *AddedFile)(char *lpFileName);
int (WINAPI *AddedKey)(HKEY hKeyRoot,char *lpPath);
int (WINAPI *AddedValue)(HKEY hKeyRoot,char *lpPath,char *lpValueName);
int (WINAPI *AddShared)(char *lpSharedFile);
int (WINAPI *BackupFile)(char *lpFileName);
int (WINAPI *CreateDirectory)(char *lpDirectory);
char *lpCommandLine;
HBITMAP hbmDialog;
BOOL bSilent;
DWORD *lpdwFlags;
char *(WINAPI *GetVariableString)(char *lpVariable);
int (WINAPI *GetVariableInt)(char *lpVariable);
int (WINAPI *SetVariableString)(char *lpVariable,char *lpValue);
int (WINAPI *SetVariableInt)(char *lpVariable,int iValue);
} AdvancedStruct;AdvancedStruct *g_pADS = NULL;long WINAPI AdvancedEntry(AdvancedStruct *lpAdvancedStruct)
{
g_pADS = lpAdvancedStruct;
return 1;
}
具体怎么做?最好详细点,谢谢。
type
pAdvancedStruct = ^AdvancedStruct;
_AdvancedStruct = packed record
AddedFile:Function(lpFileName:PChar):Integer; stdcall;
AddedKey:Function(hKeyRoot:HKEY; lpPath:PChar):Integer; stdcall;
AddedValue:Function(hKeyRoot:HKEY; lpPath:PChar; lpValueName:PChar):Integer; stdcall;
AddShared:Function(lpSharedFile:PChar):Integer; stdcall;
BackupFile:Function(lpFileName:PChar):Integer; stdcall;
CreateDirectory:Function(lpDirectory:PChar):Integer; stdcall;
lpCommandLine:PChar;
hbmDialog:HBITMAP;
bSilent:Boolean;
lpdwFlags:PDword;
GetVariableString:Function(lpVariable:PChar):PChar; stdcall;
GetVariableInt:Function(lpVariable:PChar):Integer; stdcall;
SetVariableString:Function(lpVariable:PChar; lpValue:PChar):Integer; stdcall;
SetVariableInt:Function(lpVariable:PChar; iValue:Integer):Integer; stdcall;
end;
AdvancedStruct = _AdvancedStruct;var
g_pADS:pAdvancedStruct;Function AdvancedEntry(lpAdvancedStruct:pAdvancedStruct):LongWord; stdcall;
begin
g_pADS := lpAdvancedStruct;
ResUlt := 1;
end;