问题解决了,自己动态导入 dll
type
PTSTR = PAnsiChar;
PPSTR = ^PTSTR;
TSetupCopyOEMInf = function(const SourceInfFileName, OEMSourceMediaLocation: PTSTR;
OEMSourceMediaType, CopyStyle: DWORD; DestinationInfFileName: PTSTR;
DestinationInfFileNameSize: DWORD; RequiredSize: PDWORD;
DestinationInfFileNameComponent: PPSTR): BOOL; stdcall;
const
SPOST_PATH = 1;
SP_COPY_NEWER_OR_SAME = 4;
procedure TForm1.Button1Click(Sender: TObject);
var
SetupApi: DWORD;
SetupCopyOEMInf: TSetupCopyOEMInf;
begin
SetupApi := LoadLibrary('SetupApi.dll');
if SetupApi <> 0 then
begin
@SetupCopyOEMInf := GetProcAddress(SetupApi, 'SetupCopyOEMInfA');
SetupCopyOEMInf(PChar(Edit1.Text), nil, SPOST_PATH, SP_COPY_NEWER_OR_SAME, nil, 0, nil, nil);
end;
end;
type
PTSTR = PAnsiChar;
PPSTR = ^PTSTR;
TSetupCopyOEMInf = function(const SourceInfFileName, OEMSourceMediaLocation: PTSTR;
OEMSourceMediaType, CopyStyle: DWORD; DestinationInfFileName: PTSTR;
DestinationInfFileNameSize: DWORD; RequiredSize: PDWORD;
DestinationInfFileNameComponent: PPSTR): BOOL; stdcall;
const
SPOST_PATH = 1;
SP_COPY_NEWER_OR_SAME = 4;
procedure TForm1.Button1Click(Sender: TObject);
var
SetupApi: DWORD;
SetupCopyOEMInf: TSetupCopyOEMInf;
begin
SetupApi := LoadLibrary('SetupApi.dll');
if SetupApi <> 0 then
begin
@SetupCopyOEMInf := GetProcAddress(SetupApi, 'SetupCopyOEMInfA');
SetupCopyOEMInf(PChar(Edit1.Text), nil, SPOST_PATH, SP_COPY_NEWER_OR_SAME, nil, 0, nil, nil);
end;
end;