主 Delphi 程序单元(vxdProcs.pas) ... procedure ShellMessage(Handle, Flags : integer; const Message, Caption : PChar; Callback, ReferenceData : pointer); stdcall; assembler; asm mov ebx, Handle // virtual machine handle mov eax, Flags // message box flags mov ecx, Message // address of message text mov edi, Caption // address of caption text mov esi, Callback // address of callback mov edx, ReferenceData // reference data for callback
int 20H // VxDCall dd 170004h // Shell_Message end;
function SysDynamicDeviceInit : INTEGER; begin ShellMessage(0, $10, Copyright, 'SysDynInit: Hello from Delphi VxD !!!', nil, nil); Result := VXD_SUCCESS; end;
function SysDynamicDeviceExit : INTEGER; begin ShellMessage(0, $10, Copyright, 'SysDynDevExit: Bye from Delphi VxD !!!', nil, nil); Result := VXD_SUCCESS; end;
if (dwService = DIOC_OPEN) then begin Result := NO_ERROR; end else if (dwService = DIOC_CLOSEHANDLE) then begin Result := VXD_SUCCESS; end else if (dwService > MAX_PASVXD_W32_API) then begin Result := ERROR_NOT_SUPPORTED; end else begin Result := VXD_SUCCESS; end; end; ...
function TVxDTestForm.OpenVxDDriver: boolean; begin HVxDHandle := CreateFile(VxDName,0,0,nil,0,FILE_FLAG_DELETE_ON_CLOSE,0); Result := HVxDHandle <> INVALID_HANDLE_VALUE; end;
procedure TVxDTestForm.CloseVxDDriver; begin if HVxDHandle <> INVALID_HANDLE_VALUE then begin CloseHandle(HVxDHandle); HVxDHandle := INVALID_HANDLE_VALUE; end; end