473,809 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_c all,
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 *InitDllOperati on)();
int main(int argc, char* argv[])
{

InitDllOperatio n initDll;

HINSTANCE dllLib = LoadLibrary("Te stDll.dll");

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

initDll =
(InitDllOperati on)GetProcAddre ss((HINSTANCE)d llLib,"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 1408
* 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...@g mail.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(expo rt)
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
15785
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 Visual Studio Project, the SQLAddin references a compiled COM object built with Visual Studio 6.0 called SQLOld.dll. When I complie the project I get the following files in my \bin directory SQLAddin.dl SQLAddin.pd SQLAddin.tl Interop.SQLOld.dl ...
1
2591
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 looking for a robust solution for a major application. Almost every developer seems to come up with a completely different solution. While many of them are not bad, I really want a very good one. My database is SQL Server 2000 and I am using Visual...
2
7258
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). Posts concerning this topic are common, but none of the posted solutions I've tried work correctly with the above software. The linker can't seem to find the dll (reports 'unresolved external symbol __imp__IMSL_FUN@8'; IMSL_FUN.dll is the f77...
15
2104
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 Studio.NET installed. Nothing but headaches. Continually getting System.Data.SqlClient.SqlException : Timeout expired message - The timeout period elapsed prior to completion of the operation or the server is not responding. Can anyone help with...
0
1045
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 the production location. However, I didn't have any trouble running the program on any pcs that had visual studio 2003 installed on it. So, there was no problem with any development machines. However, some non-development machines would run the...
1
4039
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 provided with a set of Dll that implement the proxy needed to consume this web service. I'm now wrapping these dlls in a .Net webservice that can be consumed with Visual studio the familliar way.
9
3808
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 runtime library (compiler option /MD )everything works fine on my PC. But when I try to run the thing on a friends PC or my laptop I get: "This application has failed to start because the application configuration is incorrect.
10
1934
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 been asked to publish by copying the files manually instead. I stopped IIS for the application, deleted the application files and subfolders from the server, copied the files and folders from my local PC's project,
0
9721
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7661
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.