Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / February 2004



Tip: Looking for answers? Try searching our database.

Help needed w/ DLL Interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank Alviani - 27 Feb 2004 20:45 GMT
Hello all,

I am writing a small DLL of utility functions in VC++ 6 which must be
usable from VB 6. The functionality isn't particularly platform
specific, and I have a good deal of Mac programming experience in C++ -
and some in MS VB - just not enough in VC++. I'm having a problem with
setting up a function (from VB's viewpoint a Sub) to fill in a string -
I keep getting a Runtime Error 49 - Bad Calling convention. Here is an
extract of the code involved:

Declare Sub DisplayVersion Lib _
"D:\Clients\Henry\DLLv1\VBTest\CopyProtUtilityDLL.dll" _
(ByVal versionInfo As String)

   Dim sText As String
   ' Allocate string buffer
   sText = String$(256, vbNullChar)
   DisplayVersion sText      ' <-- error highlighted here

--------------

.h file:

#ifdef __cplusplus
  #ifndef __CPROTUTIL__
  #define __CPROTUTILLIB__ extern "C" __declspec(dllimport)
  #else
  #define __CPROTUTILLIB__ extern "C" __declspec(dllexport)
  #endif
....
#endif

__CPROTUTILLIB__ void DisplayVersion(LPSTR szVersionInfo);
  // returns copyright notice and version number

.cpp file:

// returns copyright notice and version number
__CPROTUTILLIB__ void DisplayVersion(LPSTR szVersionInfo)
  {
  sprintf(szVersionInfo, "%s", "Version 0.1 (c)2004");
  }

Please note that __CPROTUTIL__ is defined on the compiler command line
to force the export mode.

Thanks in advance - I'm sure this is going to be something dumb, but I
just can't see it!!

Frank Alviani
bono - 28 Feb 2004 16:29 GMT
Sorry, I read English a little bit, but not write.
It is pardon when it is strange English.

Window's dll call rule is not 'C' but 'pascal'.
Please insert keyword WINAPI to function.
and inset DEF file into project.

example.
CopyProtUtilityDLL.def:
LIBRARY    CopyProtUtilityDLL
EXPORTS
    DisplayVersion    @1

.cpp file:
// returns copyright notice and version number
__CPROTUTILLIB__ void WINAPI DisplayVersion(LPSTR szVersionInfo)
  {
  sprintf(szVersionInfo, "%s", "Version 0.1 (c)2004");
  }

- bono
Frank Alviani - 29 Feb 2004 13:46 GMT
> Sorry, I read English a little bit, but not write.
> It is pardon when it is strange English.
[quoted text clipped - 17 lines]
>
> - bono

Thanks ever so much - that was exactly what I needed!

Your slight difficulty with English is not important - your
thoughtfulness and clarity in explanation is :)

Frank Alviani
bono - 28 Feb 2004 16:38 GMT
Sorry, I read English a little bit, but not write.
It is pardon when it is strange English.

Window's dll call rule is not 'C' but 'pascal'.
Please insert keyword WINAPI to function.
and inset DEF file into project.

example.
CopyProtUtilityDLL.def:
LIBRARY    CopyProtUtilityDLL
EXPORTS
    DisplayVersion    @1

.cpp file:
// returns copyright notice and version number
__CPROTUTILLIB__ void WINAPI DisplayVersion(LPSTR szVersionInfo)
  {
  sprintf(szVersionInfo, "%s", "Version 0.1 (c)2004");
  }

- bono
bono - 28 Feb 2004 16:53 GMT
I'm very very sorry.
It seems that it has sent twice by mistake.
Please Allow.
- bono
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.