Entwickler-Ecke

Windows API - GetProcAddress, nicht per Namen exportierte DLL-Funktion


mderinger@netcom.de - Di 01.08.06 08:41
Titel: GetProcAddress, nicht per Namen exportierte DLL-Funktion
Die Shell32.Dll exportiert die Funktionen ShSetFolderPathA (231) und SHSetFolderPathW (232). Die Funktionen werden jedoch nicht per namen exportiert sondern können nur über ihren Index (Ordinary-Value) erreicht werden.

1. Versuch:

Delphi-Quelltext
1:
2:
3:
4:
  Procedure shSetFolderPath(Clsid:DWord; hToken:THandle; DWFlags:DWord; pszPath:pChar);
            StdCallexternal 'Shell32.dll' index 232;

  //Der Aufruf dieser Funktion tut nichts!?!


2. Versuch:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
  var hshell32dll:THandle;
      pShsetFolderPath
            :procedure(Clsid:DWord;hToken:THandle;DWFlags:DWord;pszPath:pChar);
begin
    hshell32dll:=GetModuleHandle(pchar('shell32.dll'));
    @pShSetFolderPath:=getProcAddress((hshell32dll, ??lpProcName??));
end;

// ????? Wie muss ich hier den lpProcName als ordinal-Wert angeben??
// Die MSDN schreibt dazu:
//[out] Pointer to a null-terminated string containing the function name, or specifies 
//the function's ordinal value. If this parameter is an ordinal value, it must be in the 
//low-order word; the high-order word must be zero.


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.


Narses - Di 01.08.06 09:05

Moin und :welcome: im Forum!

Steht doch da:
MSDN hat folgendes geschrieben:
Pointer to a null-terminated string containing the function name, [highlight]or specifies
//the function's ordinal value. If this parameter is an ordinal value, it must be in the
//low-order word[/highlight]; the high-order word must be zero.

Also:

Delphi-Quelltext
1:
@pShSetFolderPath:=getProcAddress(hshell32dll,Pointer(232));                    

cu
Narses

PS: Nimm doch nächstes mal bitte die Delphi-Tags, kann man den Code besser lesen. ;)