SME
Wed Dec 12 20:28:16 PST 2007
Thanks Igor.
Hmm, then I have to learn how COM server works also.
However the actual function name exported is present in the error message
that I had given in my original post. Getting the address of that function,
was running.
Appending of a random unique code to a sensible function name appears to be
absurd. Why it was done? There was no mention of that in any of the help
docs. That's cheating. So there must a decent way to reclaim the original
function names. Probably the "Function Table" method must be working better.
But I don't think the help docs were mentioning this method as an method of
convinience rather than saying that is the way to do. Also the help doc
"DLLs in Wind32" talks about some .DEF files in its example code. How to
creat this .DEF file? When I added a .DEF file and added "exports ..." the
compiler said "exports" is not valid for the platform so ignored it. What is
this?
Actually I tried that method also but in vain. I will try it again.
ThanQ...
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:%23Eh9nmRPIHA.1184@TK2MSFTNGP04.phx.gbl...
> SME <smelchuri@hotmail.com> wrote:
>> You are asking me to 'Load the DLL imlicitly'. I have tried it and
>> works fine. For that I don't have to do any changes to what the App
>> Wizard had created.
>>
>> I want to test loading it explicitly / dynamically as eventually I
>> will be using it with a VB6 program.
>
> For that, you need to export plain C API - a set of standalone functions
> (similar to how Win32 API does it). VB wouldn't know what to do with a C++
> class.
>
> Even from a C++ client, using LoadLibrary/GetProcAddress on an exported
> class, while possible, is completely impractical. The DLL doesn't really
> export a class - it exports each method, as well as constructors and
> destructors, as a standalone function with a weird name.
>
> Alternatively, make your DLL a COM server - it's much easier to use from
> VB than C API.
>
>> If I want to load it explicitly,
>> then I shouldn't link with the .lib. The sequence of operations as
>> per the help doc is:
>>
>> 1. Call LoadLibrary and get the handle - I get it, no problem.
>> 2. Call GetProcAddress to get the pointer to the external function. -
>> I realized this after posting the original problem. I do fial on
>> this. The call is not succeeding.
>
> You are likely using a wrong name. Use Dependency Walker
> (
http://www.dependencywalker.com/) to examine functions actually exported
> by the DLL, see what kind of names they are exported under. But really,
> abandon this idea, it's not workable.
>
>> 3. Call the external function - This fails in linking itself, as the
>> errors that I presented.
>
> I don't understand. You are supposed to call through a function pointer
> obtained by GetProcAddress. Linker is not involved in this.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>