Autor Beitrag
toscho
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Sa 10.05.08 18:04 
Hallo,

ich habe ein Problem mit einem DLL Aufruf.
Mir liegt nachfolgendes Bsp in Visal Basic vor.

Private Declare Function DiiOpenDevice Lib "Dii.dll" Alias _
"_DiiOpenDevice@12" (ByVal dwDeviceType As Long, _
ByVal dwIndex As Long, ByVal bExclusive As Boolean) As Long

wie mach ich diesen Aufruf in Delphi?


Vielen Dank für Eure Hilfe.

toscho
Carlo91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 20



BeitragVerfasst: Sa 10.05.08 18:37 
Hi,

du könntest die DLL in Delphi auch Statisch laden so wie in Visual Basic:

ausblenden Delphi-Quelltext
1:
function DiiOpenDevice(dwDeviceType: DWORD; dwIndex: DWORD; bExclusive: Boolean): DWORD; external 'Dii.dll' name '_DiiOpenDevice@12';					


oder du könntest Sie Dynamisch laden:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
procedure Test;
var
  dwError: DWORD;
  hLibrary: HMODULE;
  DiiOpenDevice: function (dwDeviceType: DWORD; dwIndex: DWORD; bExclusive: Boolean): DWORD;
  //dwResult: DWORD;
begin
  if (FileExists('Dii.dll')) then
  begin
    hLibrary :=LoadLibraryA('Dii.dll');
    dwError :=GetLastError;
    if (hLibrary <> 0then
    begin
      @DiiOpenDevice :=GetProcAddress(hLibrary, '_DiiOpenDevice@12');
      dwError :=GetLastError;
      if (@DiiOpenDevice <> Nilthen
      begin
        //dwResult :=DiiOpenDevice(0, 0, False); //Hier die Function benutzen...
      end else
      begin
        MessageBoxA(0, PChar(SysErrorMessage(dwError)), 'Error', MB_OK or MB_ICONERROR);
      end;
    end else
    begin
      MessageBoxA(0, PChar(SysErrorMessage(dwError)), 'Error', MB_OK or MB_ICONERROR);
    end;
  end else
  begin
    dwError :=GetLastError;
    MessageBoxA(0, PChar(SysErrorMessage(dwError)), 'Error', MB_OK or MB_ICONERROR);
  end;
end;


P.S. Ich hoffe ich hab keine Fehler in den codet gemacht... hab es eben nur schnell im Notepad geschrieben

MfG Carlo
toscho Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Sa 10.05.08 21:10 
Hallo Carlo,

vielen Dank,für Deine schnelle Antwort.

Die Anweisung hat ganz gut geklappt.

Nur hab ich jetzt ein anderes Problem.

Aus der DLL wird die Meldung "embedded window function not support yet" generiert.

Diese Meldung kommt auch, wenn ich direkt die exe starte.

Es ist ja wohl kein Delphi Problem, aber viellecht kann mir trotzdem jemand helfen.

Ich habe XP Prof, SP2 auf meinem Rechner.

Vielen Dank schon mal für Eure Hilfe.

toscho