| Title: | Microsoft Visual Basic |
| Moderator: | TAMARA::DFEDOR::fedor |
| Created: | Thu May 02 1991 |
| Last Modified: | Thu Jun 05 1997 |
| Last Successful Update: | Fri Jun 06 1997 |
| Number of topics: | 2565 |
| Total number of notes: | 10453 |
Does anyone help me for the following problem ?
I have to call DLL file written by Visual C from VisualBasic V4.0
and all have to be programmed with 32bit option because the DLL file should
call another 32-bit DLL.
But in execution time, the VB application caused some error as follows;
"Run time Error "49"
"Bad DLL calling convention"
I tested the attached sample program but the result was same.
The compiler version is
VB 4.0 with 32-bit option.
VC 4.0 respectively.
It's very critical to me because we don't have much time to finish customer
project.
Hope to hear any kinds of hints or answers.
Thanks in advance.
/Dong-won
--------------------------------- ATTACHMENT ---------------------------------
* Visual Basic Code.
Attribute VB_Name = "Module1"
Declare Sub plus_data Lib "TEST" (ByVal i As Long)
VERSION 4.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6555
ClientLeft = 1140
ClientTop = 1515
ClientWidth = 9150
Height = 6960
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 6555
ScaleWidth = 9150
Top = 1170
Width = 9270
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim i As Long
i = 0
plus_data (i)
End Sub
*----------------------------------------------------------------------------
* Visual C code
#include <windows.h> // required for all Windows applications
#include <stdio.h>
#pragma data_seg("SHARED_SEG")
int gUserCount = 0;
#pragma data_seg(".data")
BOOL InitializeSubsystem()
{
return TRUE;
}
BOOL InitApp()
{
return TRUE;
}
BOOL CleanupSubsystem()
{
return TRUE;
}
BOOL CleanupApp()
{
return TRUE;
}
BOOL WINAPI DllMain(HANDLE hMoudle,
DWORD dwReason,
LPVOID lpReserved)
{
BOOL bSuccess;
UNREFERENCED_PARAMETER(hMoudle);
UNREFERENCED_PARAMETER(lpReserved);
switch (dwReason){
case DLL_PROCESS_ATTACH:
gUserCount++;
if (gUserCount == 1)
bSuccess = InitializeSubsystem();
else
bSuccess = InitApp();
break;
case DLL_PROCESS_DETACH:
if (gUserCount == 1)
bSuccess = CleanupSubsystem();
else
bSuccess = CleanupApp();
break;
}
return (bSuccess);
}
int plus_data(int data)
{
data ++;
return data;
}
| T.R | Title | User | Personal Name | Date | Lines |
|---|---|---|---|---|---|
| 2495.1 | ELIS::TOWERS | Fri Feb 14 1997 03:30 | 12 | ||
Dong-won, this sort of thing has been done by a number of people in
this conference and, what's more, they've documented it in this
conference. If you search the conference you will find what you want.
Hint: DIR/tit="DLL" should get you started
Cheers,
Brian
PS It is good notes etiquette to do this kind of search BEFORE writing
a note. That way the conference doesn't get cluttered up with notes
asking the same question over and over again.
| |||||