I have created a VB DLL using the code given below. And then I tried to use that DLL in an VC++ Win32 application. Where the LoadLibrary/AfxLoadLibrary were working ok. But the GetProcAddress calls always returning NULL. Can anybody help?
VB Dll code:
Public Function LoadResourceInteger(ByVal theStringID As Integer) As Integer
LoadResourceInteger = 0
On Error GoTo ErrMsg
LoadResourceInteger = 1000
Exit Function
ErrMsg:
LoadResourceInteger = 0
MsgBox ("Resource:missing in MUI Resource File.") ' MUI - Multilanguage User Interface
End Function
VC++ Win32 App uses that VB DLL:
typedef int (__stdcall *LoadRessString)(int argument1);
HINSTANCE hMod;
hMod = AfxLoadLibrary("MUIResourceEnglish.dll");
if(NULL == hMod)
{
MessageBox("Object Not Created","Caption",MB_OK);
return;
}
else
{
LoadRessString localLoadResString;
localLoadResString = (LoadRessString) GetProcAddress(hMod,"LoadResourceInteger");
if(localLoadResString == NULL)
{
MessageBox("GetProcAdress Failed","Caption",MB_OK);
FreeLibrary( hMod);
return;
}
int myResString = localLoadResString(1);
MessageBox("Success","Caption",MB_OK);
return ;
}GetProcAddress(hMod,"LoadResourceInteger");
if(localLoadResString == NULL)
{
MessageBox("GetProcAdress Failed","Caption",MB_OK);
FreeLibrary( hMod);
return;
}
int myResString = localLoadResString(1);
MessageBox("Success","Caption",MB_OK);
return ;
}
Jothi Murugeswaran.S
5 4821
HI...
ops man, visual basic 6.0 just can export COM classes it cant export function as API, just you can call class members that exported by VB6 from VC++ by using import directive or COM API functions -
#import "yourCOMdll.dlll"
-
or you can use COM API functions as CoCreateInstance, CoGetobject as so on....
finally GetprocAddress is working only with Dll have API as Windows API kernel.dll and user32.dll and this type of dll VB6 cannot export but if you reverse your operaion it will work, you can create dll from VC++ that you can use from VB6 by GetProcAddress and LoadLibrary
GOOD LUCK...
HI...
ops man, visual basic 6.0 just can export COM classes it cant export function as API, just you can call class members that exported by VB6 from VC++ by using import directive or COM API functions -
#import "yourCOMdll.dlll"
-
or you can use COM API functions as CoCreateInstance, CoGetobject as so on....
finally GetprocAddress is working only with Dll have API as Windows API kernel.dll and user32.dll and this type of dll VB6 cannot export but if you reverse your operaion it will work, you can create dll from VC++ that you can use from VB6 by GetProcAddress and LoadLibrary
GOOD LUCK...
Thanks for reply
How to use the cocreateinstance?
HI...
COM API Functions as CoCreateInstance it not just a function call , it need more knowledge about COM Objects, this link may be help you http://msdn2.microsoft.com/en-us/library/ms686615.aspx
Kind Regards
I need an example for that....
and also i want to make sure that , by using this method can we access the functions(without hardcoding import, idl,..) present in the activex dll created in vb?
HI..
ok i will get you an example in my second post, but there is no third way to do that within VC++, only Import Directive and COM API Functions can be used to create COM Objects.
Bext Regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: DMamoun |
last post by:
I am trying to call a fuction a a C# dll using the
GetProcAddress, but the returned handle is null, wheras
the LoadLibrary of the container dll succeeds, I write
the function name as it is written...
|
by: Siegfried Heintze |
last post by:
I have some C functions I need to expose as XML web services. My original
plan was to deply an XML Web service in C# and use P/Invoke to call my C
functions. This is not working because the web...
|
by: Anthony Gallagher |
last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to
recompile one of our projects using VC++ .NET. I get all kind of linker
errors (specially in STL calls). How do I get rid of...
|
by: Bill Cumming |
last post by:
Is there something about C++ / C# interop that initializes the threading
model to MTA so that OleInitialize will fail?
I have a mostly C++ app that calls a single C# class DLL. Only one source...
|
by: John Cullen |
last post by:
I have uncovered an interesting problem with resource only DLLs. If I
create a project with a long name and the name includes periods ("."), the
IDE will fail to kick off the linker. The resource...
|
by: Harry Whitehouse |
last post by:
I'm porting an application from Borland C++ to VS .NET 2003. The VC++
compiler doesn't want to deal with declarations like this in my code:
LONG FAR PASCAL _export StdPVDlgProc(HWND hWnd, UINT...
|
by: Craig Dunstan |
last post by:
I am using C# to write a web service, which relies on some underlying
functionality in a third party DLL. I have been reliably informed that I
should not use static binding to the DLL as this will...
|
by: Siegfried Heintze |
last post by:
I have some C functions I need to expose as XML web services. My original
plan was to deply an XML Web service in C# or VB and use P/Invoke to call my
C functions. This is not working because the...
|
by: huckjam |
last post by:
Well I have this code so far:
Public Declare Function GetProcAddress Lib "kernel32" (ByVal ModuleHandle As Integer, ByVal ProcName As String) As Integer
Public Declare Function LoadLibrary Lib...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |