unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
pfnHotPlugEjectDevice = function (hwndParent: HWND; DeviceInstanceId: string) : Boolean;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
HotPlugEjectDevice: pfnHotPlugEjectDevice = nil;
procedure TForm1.Button1Click(Sender: TObject);
var
hHotPlug:HMODULE;
res:boolean;
begin
res:=false;
hHotPlug := LoadLibrary('HotPlug.dll');
if hHotPlug = 0 then
begin
showmessage('ERROR in LoadLibrary(HotPlug.dll) Error nr: '+IntToStr(GetLastError));
end
else
begin
showmessage('Wszystko ok!'+#13+'Ladujemy funkcje! z hotplug.dll');
@HotPlugEjectDevice := GetProcAddress(hHotPlug, 'HotPlugEjectDevice');
res := HotPlugEjectDevice(Handle, 'USB\VID_090C&PID_1000\AA04012700007695');
if res = true then
ShowMessage('udalo sie odlaczyc pendrive''a')
else
ShowMessage('NIE udalo sie odlaczyc pendrive''a :(((( !!!!'); // <<------- tutaj caly czas sie wysypuje poprostu nie odlacza pendriv'a
FreeLibrary(hHotPlug); Caption := 'zwolniono bibliotekę hotplug.dll';
end;
end;
end.
Post z przed wielu lat http://4programmers.net/Forum/viewtopic.php?id=119996 i w sumie patrze i nie wiem jak zmienic res := HotPlugEjectDevice(Handle, 'USB\VID_090C&PID_1000\AA04012700007695');
bo zapewne tu jest kłopot.