473,383 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Looking for some help, problems with C++ Dlls (Using Visual Studio C++ 6.0)

Hi everyone. Okay, I'm trying to dynamically link some dlls and I'm
having some problems. I originally had a project that seems to work,
but for the life of me I can't repeat the results.

I used app wizard to create a simple Win32 Dynamic Linked library. the
code is as follows:
#include "stdafx.h"
#include "stdio.h"

int i = 0;

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

void _stdcall InitDll(){
i = 1;
}

I build that and get 'TestDll.dll'

The program I use to open this dll looks like this:
#include "stdafx.h"
#include <windows.h>
typedef void(__stdcall *InitDllOperation)();
int main(int argc, char* argv[])
{

InitDllOperation initDll;

HINSTANCE dllLib = LoadLibrary("TestDll.dll");

if( dllLib == NULL )
{
printf( "Unable to load library\n");
return 1;
}
else
{
printf( "loaded library successfully\n");
}

initDll =
(InitDllOperation)GetProcAddress((HINSTANCE)dllLib ,"InitDll");

if( initDll == NULL )
{
printf( "initDll failed to load\n");
return 1;
}
else
{
printf( "init Success\n");
}

return 0;
}
Every time the library loads successfully, but the 'initDll' object is
ALWAYS Null. The return from GetProcAddress seems to always come up
null. Any suggestions?

Thanks

Jan 24 '07 #1
2 1390
* Dave:
Hi everyone. Okay, I'm trying to dynamically link some dlls and I'm
Well, that belongs in a Windows programming newsgroup, sorry.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jan 24 '07 #2


On Jan 23, 10:37 pm, "Dave" <davechand...@gmail.comwrote:
Hi everyone. Okay, I'm trying to dynamically link some dlls and I'm
having some problems. I originally had a project that seems to work,
but for the life of me I can't repeat the results.
[ snip ]
>
}Every time the library loads successfully, but the 'initDll' object is
ALWAYS Null. The return from GetProcAddress seems to always come up
null. Any suggestions?
Hello Dave,

Your question is off topic here, but you can check two things:

1. Exporting functions from DLLs requires using __declspec(export)
2. Name mangling needs to be disabled on exported functions. Mangled
names may not be what you expect, so GetProcAddress may not find the
function you want.

Search for some sample code on Google. There are plenty of good
examples available.

But again, this question is off topic here. :-)

Regards,
Markus.

>
Thanks
Jan 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut | last post by:
Hi. Let me explain the setup. I am using Visual Studio .NET to develop a sort of add-in (COM class) for Excel called SQLAddin. It basically queries a SQL server and pulls in data. Now within my...
1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
2
by: | last post by:
Help! I'm new to c++, and am breaking my teeth on MS Visual C++ (bundled within Visual Studio .NET 2003). Am trying to link simple c++ code to fortran dlls created in Compaq Visual Fortran (v6.1)....
15
by: DavidS | last post by:
Have Visual Studio.NET installed on MS 2000 Professional OS laptop. No issue ever with web development and SQL connections. Purchased new laptop with XP Professional SP2!!!!!!!! & Visual...
0
by: mike | last post by:
Recently I posted a message about deploying an application over a network. I had the .net framework installed on the pcs, the local intranet set to full trust, and I had copied the bin directory to...
1
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
9
by: Andreas Schmitt | last post by:
I am workin on a 2 part project right now. The first part is a DLL, the second part a normal exe using that DLL. When I use the VS2005 standard setting for compiling with the Multithreaded-DLL...
10
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I usually deploy my ASP .NET application to the server by publishing, using Visual Studio 2005 publish feature. This creates the Bin folder on the server, with the compiled DLLs. I've...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.