Einzelnen Beitrag anzeigen

Apollonius

Registriert seit: 16. Apr 2007
2.325 Beiträge
 
Turbo Delphi für Win32
 
#23

Re: [Delphi] ASM => applicationdata

  Alt 7. Mär 2008, 15:53
Weil du es bist:
Delphi-Quellcode:
function GetShellFolder(CSIDL: Integer): PChar;
asm
  push eax //das ist die Variable PIDL
  push esp
  push eax
  push 0
  call SHGetSpecialFolderLocation
  test eax, eax
  jnz @@ExitProc
  push MAX_PATH
  push GMEM_FIXED
  call GlobalAlloc
  pop edx
  push eax
  push eax
  push edx
  call SHGetPathFromIDList
  pop eax
  @@ExitProc:
end;
Allgemein ist test Register, Register besser als cmp Register, 0, da es in 2 statt 3 Bytes codiert wird. Außerdem ist bei GMEM_FIXED bzw. GPTR kein GlobalLock notwendig.
Des Weiteren führt der Code (auch meiner) zu einem Speicherleck: PIDL soll man laut MSDN mit dem IMalloc der Shell freigeben.
Wer erweist der Welt einen Dienst und findet ein gutes Synonym für "Pointer"?
"An interface pointer is a pointer to a pointer. This pointer points to an array of pointers, each of which points to an interface function."
  Mit Zitat antworten Zitat