 |
|
 |
In all honesty it is simple, yet understandable, but another example would make a difference.
|
|
|
|
 |
|
 |
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
|
|
|
|
 |
|
 |
I had tried with Case2, But it is not working properly....
It is loading the dll, but not loading the function(ie, We cant able to call the functions present in the Dll) , Do u have any other idea?
Jothi Murugeswaran.S
|
|
|
|
 |
|
 |
Thanks very much for posting this article, it was just what I needed to get started with the optional loading of dlls in my project. You probably saved me hours if not days!
--Nick--
|
|
|
|
 |
|
 |
Hi,
I have one dll VBDll.dll which is created using Visual Basic 6.
This dll contain one function VBDllFunction().
I want to create one c++ dll CPPDll.dll.
This dll will have one function CPPDllFunction().
CPPDllFunction() function will call VBDllFunction().
Function CPPDllFunction() will be exported so as to be used by any other VB6 application. That means, I should able to call CPPDllFunction() in Visual Basic 6 project.
How can I do this ? Would you please help me to do this ?
I tried much. To do this, I need to add reference for VBDll.dll in CPPDll.dll project. I can add the reference using View menu - ClassWizard. This is only possible if I create CPPDll.dll using MFC AppWizard. But in this case, I am unable to export CPPDllFunction().
If I create CPPDll.dll using Win32 Dynamic-Link Library, then I am able to export the function CPPDllFunction(), but in this case, I am unable to add the reference for VBDll.dll.
How can I do this ? Please Help.
Amit Joshi
|
|
|
|
 |
|
 |
Hi,
It should work, I managed both to import an external function and to export my own function for access from outside of the generated dll. Choose a second approach to generate a dll, and load the external function either using a scenario 1 or scenario 2 described in the article.
Nataliya
|
|
|
|
 |
|
 |
Hi Nataliya thanks for reply.
Very first thing I would like to clear is I am very new to C++. I am working with C++ first time for last 2 weeks.
I have one dll in Visual Basic 6 that downloads url using HTTP protocol to the system cache. This dll is working very fine. No any error.
Only problem is, till dll is downloading file, application is locked. The function I am using to download url is blocking function.
I read one article on code project which was showing how to download url asynchronously so that it will not block the user interface. But that article is in C++. He have acomplished it by creating new thread in C++.
As I told you before, I am new bye to C++. I have never used C++ before. For that reason, I am unable to understood where to write the code you specified in Case 2.
My target is to import function from Visual Basic dll into C++. Write one function in C++ that will call VB function in different thread. Export C++ function outside the dll so that I can call it form Visual Basic EXE project or ASP project whatever.
So, would you PLEASE explain me what should I do step by step ?
My e_mail id is call4e_friend@yahoo.com
Thanks in advance. Waiting for your reply.
Amit
-- modified at 2:52 Thursday 12th July, 2007
|
|
|
|
 |
|
 |
I had used the return type as int ( It is not working Properly)
Jothi Murugeswaran.S
|
|
|
|
 |
|
 |
It's great to see a girl here, especially a good looking one.
Hey Nat, are you single ? Care for a drink ? Call me !
|
|
|
|
 |
|
 |
hi nataliya,
what is the difference between loadlibrary and afxloadlibrary? How do I know that it is multi threaded or single threaded?
|
|
|
|
 |
|
|
 |
|
 |
hi... nataliya mullyar , i have learnt C, C++, during my Engineering course , just willing to learn ATL , COM , DLL , WTL , which i dont know about these... plz help me to learn and suggest some good books to begin learning with ..... thanks a lot
please mail me at : thukaram_vh@yahoo.com
:-Oregards
take care n waiting for ur reply, bye..
thukaram_vh@yahoo.com
|
|
|
|
 |
|
 |
Could you please NOT post any messages the subject of which is not directly related to the subject discussed in this article?
Thanks a lot!
|
|
|
|
 |
|
 |
Can i free the memory allocated in an exe, in a DLL??
u r very pretty....nataliya me email address is rahulkarn@yahoo.com
am waiting for ur mail
-- modified at 4:00 Tuesday 10th January, 2006
|
|
|
|
 |
|
 |
Hi, Nataliya,
thanks for your article, it's just what I needed.
Well, I was also trying to load a dll in Rose Real Time as an Add-In.
What I mean, is, create the dll using your procedure in Visual C++ and use it as some add-in in Rose Real Time.
Most of the articles describe how to do it in Visual Basic, but I had no luck finding how to do it in Visual C++.
Thank you,
Daniel
-- modified at 13:02 Wednesday 21st December, 2005
|
|
|
|
 |
|
 |
Happy Birthday again ! Good Luck and best wishes !
|
|
|
|
 |
|
 |
Hello.
First of all, im sorry if this doesnt quite belong here, but i noticed people are quite active in here and know what they are talking about, so ill try.
The problem is this:
I have a header, includes.h, containing a variable like : MY_STR *my_str;
This header is part of three different dll projects.
I build the dlls.
The main app also has includes.h included.
The main app at its beginning allocates memory for my_str and initializes it.
But when i debug and trace the variable my_str into either one of my dlls, it is always NULL.
What can i do so that my_str would be perfectly visible and usable inside my dlls?
Thank you in advance.
|
|
|
|
 |
|
 |
I don't remember the exact syntax, but you need to specify that the variable is shared, so that other applications and dll's may access it. Otherwise dll's run in different memory spaces than the application does, thus pointing nowhere.
Regards, Nataliya
|
|
|
|
 |
|
 |
Thanks for your quick answer.
Well, i tried that. In all off my dlls, which have this MY_STR *my_str, i've rewritten it like this:
#pragma data_seg("SHARED")
MY_STR* my_str;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")
I took it from here : http://www.codeproject.com/dll/data_seg_share.asp#xx919436xx
The problem is, i get these warnings when i try to compile either of them:
LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist
So i'm probably not doing something right....
|
|
|
|
 |
|
 |
This is indeed the code snippet I was talking about. I'm not sure that I can help you with this error, perhaps it's wise to check the correctness of the declaration and whether you exported it properly.
- Nataliya -
|
|
|
|
 |
|
 |
Hi.
The problem is solved by putting the declaration in the innermost dll's c file and using declspec import on it in the header file.
Thanks for your help.
|
|
|
|
 |
|
 |
Initialize your variable in the shared segment to stop this warning from coming.
|
|
|
|
 |
|
 |
I am trying to develop a learning exercise for young students to schedule their tasks for each week. My aim is to use resizable blocks (rectangles) that can vary in colors depending on how critical that task has become for the student. All bolcks can vay in height depending on how much time the student thinks needs to accomplish it. Blocks should be drawn as moveable items (drag&drop) so students can place the item on top of other items on a time scale Y coordinate (hours) for each weekday X coordinate.
I have though to make use of cards.dll or something like it in Visual Basic 6.0 to accomplish such program, but have no idea on how to tap on cards.dll
Could you guide me on how to do this or if there is a better way (easiest) to do it?
Michael
|
|
|
|
 |
|
 |
Dear Michael,
I'm not aware of the interface in Visual Basic for loading the dll's, I could help you only with C++.
Regards,
Nataliya
|
|
|
|
 |
|
 |
Dear Nataliya,
I read your article about "loading a dynamic link library (DLL) into a Microsoft Visual C++ 6.0 project". It is good and perfect.
But, I am working in Industrial automation field and have designed my real time application with ROSE-RT. Now i need to creat an interface in VC++ for controlling and calling some methods in ROSE_RT. Please help how can i do this
Mehdi Abolghasemi,
|
|
|
|
 |