I am having issues using an imported type library in Delphi 2010 and cannot for the life of me get my head around how to fix it.
ActiveDs_TLB
defines the following:
function SetSearchPreference(var pSearchPrefs: ads_searchpref_info; dwNumPrefs: LongWord): HResult; stdcall;
I assume then this requires a pointer to an array of ads_searchpref_info, but I can't do the following:
SetSearchPreference(@MySearchPref,1);
because I then see the dreaded E2033 Types of Actual and formal var parameters must be identical
error
Further down, ActiveDs_TLB
defines:
function ExecuteSearch(pszSearchFilter: PWideChar; var pAttributeNames: PWideChar;
dwNumberAttributes: LongWord; out phSearchResult: Pointer):HResult; stdcall;
but then when I try to pass a nil
as the second parameter it complains again.
Edit 1:
The tlb is from Golez as part of the answer to http://www.stackoverflow.com/questions/4184306 - the code above is from his answer - this equates to the issues I've had also getting adsi to work.
开发者_高级运维I am using W7 64 bit - that shouldn't make a difference as the adsi dll is 32 bit.
Edit 2:
I mistakenly assumed the issue was with the function due to the error hitting there because I blindly followed the code. After throwing in a few error traps, it seems the object is never created, which of course throws the av when I try to assign a value to it.
Answer assigned as it was the first to point out the obvious!
If it's defined as a var parameter, it means you should only pass a single element, and let Pascal take care of the pointer. If the original library is expecting an array, because pointers and arrays are interchangeable in C, then your TLB translation was done wrong.
The first one takes a parameter of type ads_searchpref_info
. This is probably not a pointer.
On the 2nd one, since it's a var
parameter you can't pass a constant, it must be a variable since it expects to be able to change it / pass information back out.
精彩评论