• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Visual c++ 2005 help

intelbrain

Limp Gawd
Joined
Aug 3, 2001
Messages
313
So i have this mfc *.dll plus *.h file. I can't not make it work with CLI/C++. Is this possible or i have to use mfc 2005?

I tried the Dllimport thing and it doesn't work.
 
You havent really told us enough to help you out. Tell us what you've got (specifically) and what you are trying to do.
 
the dll has all the functions that i need. I want to use the function in CLI/C++ but it doesn't work.
 
Well, I was hoping for you to name your dll... But anyway, in general with a dll you can either link with an import library to automatically handle everything or do it yourself at runtime. A static import library makes life easy and I would really hope you have one. It should have a .lib extension and you would link to it like you would with any static library. If not the only other way I know how to use your dll is to use loadlibrary() for *every* function you are going to use from that library. -- I havent much experience with doing so with c++ functions, which may complicate things due to name decoration, but I'll dig up an example for using load library in a second if you must.

Edit: I may be leading you down the wrong path, give me a second as I try to figure out what you really are trying to do. (Since you wont tell me)
 
ok, lets me try to make it more clear

I have a folder it has:
name.dll
name.lib
name.h

In MFC, i can just include "name.h" and put name.dll and name.lib in the same directory and call any function defined in the name.h.

When i include name.h and call the functions in window form C++ in visual studio 2005, it doesn't compile. (It works with MFC 2005, but i prefer not to do this cause window forms is much easier)

Been googling and DllImport was the solution to use unmanage dll. But still can't get it to work.
 
I just completely missed the whole using managed c++ part for some reason. ;o)

I'm probably in worse shape than you are as I have no code to test with and havent used clr for much of anything yet. I'll see if I can conjure up an example on my comp and see if I can figure out the syntactic salt needed to get this going.
 
I'm assuming you are doing something like this:

Code:
using namespace clr;
using namespace System::Runtime::InteropServices;

typedef void* HWND;
[DllImport("user32", CharSet=CharSet::Ansi)]
extern "C" int MessageBeep(unsigned int uType);

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	MessageBeep(0);

	return 0;
}

That would work similar to how load library works, (But again, c++ name decoration may be a problem depending on how the dll was created, open it up with a text editor I suppose to see whats actually in there.) I'll keep looking to find if there is a way to automagically use the import library to enumerate the entire dll though.
 
If I am correct with the above example code, (again I havent ever used managed c++ and am assuming what I did above is managed c++) then you can simply link with the import library, include the normal header files and use the function as you would with an unmanaged code.

Code:
// link me with user32.lib

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>

using namespace clr;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	MessageBeep(0);

	return 0;
}
 
yes, i tried that but it doesn't work. I only have the header file so i can't tell much. It looks like i'm stuck with mfc.
 
Give me your dll and name a function. I will get it to work.

Edit: np, I'm trying to figure out how to compile this from the cmd line and how to view the intermediate assembly.
 
Well, the problem is that the prototypes in the header are incorrect. Right now I'm trying to get it working in plain unmanaged c++, but am getting a missing multicam.dll message. (not to mention the header you sent me wouldnt compile to begin with)

I still havent tried the first method I mentioned, I'll play with it and get back to you if I can reverse engineer these prototypes some how.
 
Windows is looking for multicam.dll before your program even loads and since it cannot find it, it never executes. I'm 100% sure that if you can load your dll in unmanaged c++ and make a function call, that it will in turn work in your unmanaged version.

Edit: Maybe some one else can help you from here, but I'm guessing that the clr exception isnt necessarily thrown because it cant load your dll, but rather that it cannot load it's dependacy multicam.dll

Tomorrow I might make two dlls with one depending on the other to see if I'm right, but as far as how to load a dll in managed c++, you simply import the static library and the compiler will do the work for you.
 
with unmanage c++ it works fine, of course you need multicam.dll for it to run.

With manage c++, i get error in finding the entrypoint. This is way before multicam.dll error occurs. The problem is the way the dll is built, it was built for vc++ 6.0

EDIT: figure it out, the fucntion name was messed up.
 
Back
Top