Einzelnen Beitrag anzeigen

Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#61

Re: Zugriffsverletzung ADSI, so was komisches hab ich noch n

  Alt 24. Feb 2010, 14:11
You are doing something VERY wrong!
First you declare ptrResult as THandle:
  ptrResult: THandle; Later on you cast it to a pointer:
hr := search.ExecuteSearch(LPCWSTR(searchfilter), @AttrArray[0], dwCount, Pointer(ptrResult)); You are actually lucky that it works because a pointer is actually a dword therefore it works but the correct way would IMO be:
ptrHandle: PHandle;

hr := search.ExecuteSearch(LPCWSTR(searchfilter), @AttrArray[0], dwCount, ptrResult); If you need to pass it as handle later on use ptrHandle^ to derefence the pointer.

/Edit just a remark: I know this is just test code but if you change a variable type ALWAYS change it's name as well as you WILL confuse yourself later on ( or DelphiPraxis members reading your code )
Also when you post example code, please take the effort of cleaning it up as much as possible.
See my blog blog
See our Jedi blog
  Mit Zitat antworten Zitat