Re: Using a DLL without a library / stdcall / WinAPI

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Christopher J. Holland (msnews_at_microsoft.com)
Date: 06/29/04


Date: Tue, 29 Jun 2004 07:04:35 -0700

It works with

typedef int (__stdcall * whateverproc)(int j, double k);

Thanks

-- 
Christopher J. Holland [!MVP]
http://www.mvps.org/vcfaq/
http://www.codeguru.com
http://www.codeproject.com
http://www.naughter.com/
http://support.microsoft.com/default.aspx
http://msdn.microsoft.com/howto/
http://msdn.microsoft.com/library/
http://www3.pgh.net/~newcomer
"Patrick Zou" <patrick_zou@no_spam_hotmail.com> wrote in message
news:%23E70P4VXEHA.1684@tk2msftngp13.phx.gbl...
> Boolean is the return type, or param? are you sure there is only one
param?
>
> all the functions exported by a dll is stdcall.
>
> y/
>
> "Christopher J. Holland" <msnews@microsoft.com> wrote in message
> news:OWGagyVXEHA.2572@TK2MSFTNGP11.phx.gbl...
> > Thanks for answering the stdcall. That makes sense.
> >
> > I tried the LoadLibrary, that works. Then I can get the ProcAddress /
> > Function Pointer.
> >
> > The way in which the developer defined it is
> > // function BS_File ( AFile : PChar ) : Boolean; stdcall; external
> > 'BitLink.dll';
> > I define the function as
> >     typedef int (*PROC2)(char* p);
> > I also tried it as
> >     typedef int (*PROC2)(LPTSTR);
> > I also tried it as
> >     typedef int (*PROC2)(char*);
> >
> > I am able to get the Function Pointer, no errors, but for some reason,
> > I keep getting an error which states that my function definition is
> > different from that of the DLL function.
> >
> > Do I need to use stdcall at all for this?
> >
> > Not sure if you know much about VB, but could somebody just use a DLL
> > like this, I don't believe it would work with VB as it is.
> >
> > Thanks for your help,
> > -- 
> > Christopher J. Holland [!MVP]
> > http://www.mvps.org/vcfaq/
> > http://www.codeguru.com
> > http://www.codeproject.com
> > http://www.naughter.com/
> > http://support.microsoft.com/default.aspx
> > http://msdn.microsoft.com/howto/
> > http://msdn.microsoft.com/library/
> > http://www3.pgh.net/~newcomer
> >
> > "Patrick Zou" <patrick_zou@no_spam_hotmail.com> wrote in message
> > news:O4u54OVXEHA.2364@TK2MSFTNGP12.phx.gbl...
> > > _stdcall is the so called standard calling convention, it is used by
> > PASCAL,
> > > FORTRAN, and the main function of a "C" codes, since it has be a
> standard
> > > call in order for anybody else to call. C uses C calling convention.
The
> > > difference is the parameter passing sequence,and caller/callee taking
> care
> > > of clearing stack.  one is first to last, another one is last first.
It
> > > makes it possible for C to use multiple parameters, like printf.
> > >
> > > You got to have the prototypes, the .h file in order to call the
funtion
> > of
> > > the DLL. You can definitely loadlibrary to load the DLL, after that,
you
> > > need the prototype to GetProcAddress to get the function pointer.
> > > It is mostly called staick/dynamic linking.
> > >
> > > ying/
> > >
> > > "Christopher J. Holland" <msnews@microsoft.com> wrote in message
> > > news:eG8c6FVXEHA.2544@TK2MSFTNGP10.phx.gbl...
> > > > Hi,
> > > >
> > > > I have a DLL. It does not have a library, but I do know the function
> > > > prototypes.
> > > > Since it does not have a Library, I can't do "Load Time" Dynamic
> > linking.
> > > > So, I am trying to use "Run Time Dynamic linking", but I am having
> some
> > > > trouble.
> > > >
> > > > I emailed the person who distributed the DLL and he wrote the
> following
> > > >
> > > >     "The Windows version uses Windows API
> > > >     calling conventions (ie, stdcall). This makes bindings to VB
> > > >     and most non-C platforms under Windows easy."
> > > >
> > > > I'm not sure what _stdcall is, or why it is used?
> > > > It says "The __stdcall calling convention is used to call Win32 API
> > > > functions."
> > > > Why can't I just include "Windows.h" and call some function?
> > > >
> > > > I remember using VB and registering a dll, so I tried registering
the
> > dll.
> > > > Naturally, It complained with the following message.
> > > >
> > > >     "App.dll was loaded, but the DllRegisterServer entry point was
not
> > > > found.
> > > >     This file can not be registered."
> > > >
> > > > Any ideas on how I can use the dll?
> > > >
> > > >
> > > > Refrences:
> > > > DLL
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/about_dynamic_link_libraries.asp
> > > > __stdcall
> > > >
> > >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_core___stdcall.asp
> > > >
> > > > Thanks,
> > > > Christopher J. Holland [!MVP]
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Relevant Pages