-
July 19th, 2010, 08:21 AM
#1
.exe to .dll?
Hello,
I'm fairly new to C++, still learning the ropes. I am using Visual Studio 2008 and I have a Visual C++ application that right now builds as a .exe and I'd like to see if I can have it build as a .dll. The reason being, I would like to access several functions within this application from a C# application and I read that this was a possible solution. I'd like to avoid re-writing them in C#.
Thanks in advance.
-
July 19th, 2010, 12:12 PM
#2
Re: .exe to .dll?
If you wish to link a exe to a dll you would have to include the .dll its .lib and header;
example of the dll header:
Code:
#ifndef DLLHEADER_H_INCLUDED
#define DLLHEADER1_H_INCLUDED
#ifdef DLL_EXPORT
# define EXPORT __declspec (dllexport)
#else
# define EXPORT
#endif
extern EXPORT void Dll1 ();
#endif
Then the dll.cpp
Code:
#include "stdafx.h"
#include <iostream>
#define DLL_EXPORT//* define the export and import fuction
#include "Dll.h"
EXPORT void Dll1 () {
//*What ever your code is
}
After you have built your dll. place the .lib .dll and its header in the .exe source folder then add the header like so to your .exe:
Then for the exe you type in Dll1();
like so:
Code:
#include "stdafx.h"
#include "windows.h"
#include "Dll.h"
using namespace std;
int _tmain()
{
Dll1 ();
return 0;
}
this will then work with your dll
Last edited by gaar321; July 19th, 2010 at 12:22 PM.
-
July 19th, 2010, 12:28 PM
#3
Re: .exe to .dll?
If you do not wish to rewrite the code out again (which is lazy as it can be good practice) you can get a csharp to c++ converter vise versa
-
July 19th, 2010, 12:51 PM
#4
Re: .exe to .dll?
and exe and a dll are different Project types. You'll need to create a DLL project and copy the relevant code into the DLL.
-
July 19th, 2010, 12:51 PM
#5
Re: .exe to .dll?
Originally Posted by gaar321
If you do not wish to rewrite the code out again (which is lazy as it can be good practice) you can get a csharp to c++ converter vise versa
Are you saying he's lazy for not wanting to rewrite existing code?
-
July 19th, 2010, 01:50 PM
#6
Re: .exe to .dll?
I am only encourageing for people to learn carm down
-
July 19th, 2010, 01:58 PM
#7
Re: .exe to .dll?
Originally Posted by gaar321
I am only encourageing for people to learn carm down
That doesn't make any sense.
-
July 19th, 2010, 02:05 PM
#8
Re: .exe to .dll?
I was using a sarcastic approach by saying your lazy in other words motivate your self
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|