Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using dll's in Delphi 2007

Status
Not open for further replies.

Delphiman1

Programmer
Oct 14, 2008
5
0
0
US
I need to use some functions that are written in Visual Studio 2008 .net (VB), which was made into a dll. This dll is an 'assembly' but not strong named, and it can not be resistered.
I know the function names and parameters. When I try
loadlibrary and getprocaddress
the loadlibrary returns a value, but the getprocaddress returns a NIL value. I have tried static and dynamic methods to get to the respected functions.
I have also tried to import this dll, but I do not get any list of function names. I get a few declarations and in the implementation section, I get a uses COMobj line with nothing underneath it.
Is this possible to call any of these functions? Is there something that I have missed?

Var FuncPtr: TFarProc;
DLLHandle: THandle;


DLLHandle := LoadLibrary('Licensing_XSDL.dll');
FuncPtr := GetProcAddress(DLLHandle, 'Validate_Key');

if FuncPtr <> NIL then
begin
ShowMessage('Found it');
@Validate_Key := FuncPtr;
// tempStr := Validate_Key(LicenseInfo, True);
FuncPtr:= NIL;
end
else ShowMessage('is NIL - error = ' + IntToStr(GetLastError));
FreeLibrary(DLLHandle);


In the lines above, no matter what I try, the ShowMessage is displayed and the value of the GetLastError is 127.

Is there something that needs to be done on the VB side to expose the functions? (I did not write that part).
 
AFAIK, you can't use .NET dll's directly, you must wrap them with COM and then call the COM object from delphi.

here's a thread about this subject (though it is about C#, principle stays the same)


/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
As Far As I Know

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I have read that article, but it assumes you have to have access to the c++ code and to make modifications to it. Once that is done then the rest of the instructions can be followed and use that dll.
In my case it is in VB, which I have no access to the actual code, nor able to have the developer modify that code.
I know Delphi is quite powerful, used it since D3, and feel there IS a way around this problem. With the fact that Delphi can develop .Net apps, there should be a way to get access to these embedded functions. I am writing in win32, for I need the compiled code speed.
 
there is no sensible way a win32 app (made in delphi/c/whatever) can use a managed code dll. it is up to the dll to expose it's functions. what you can do is make a delphi.net dll that references the vb.net dll and wrap it into a COM object.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks, that is what I proposed to my boss. When I opened the dll within the IDE, I was able to see everything I needed. I opened it as a type library. Now all I need to do is learn how to write a 'simple' .Net dll in Delphi.

The learning never stops for me.
I do appreciate all the help and advice you given me. This is the first place that I found where I could post a question, AND get some answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top