|
-
Jan 24th, 2003, 07:45 AM
#1
Thread Starter
Let me in ..
Standard DLL
Can someone tell me how do you make Standard DLL in VC ++. I mean what project type do you select while creating a new one to create a standard dll. What properties do you set for it. Also can we write normal c++ code inside a standard DLL. I
mean no MFC or SDK etc..
-
Jan 24th, 2003, 08:23 AM
#2
Yes to the second question. You can write normal C++ code, if not you couldn't write anything. The WinAPI is just an interface after all.
As for the project, it's "Win32 DLL" in VC++6 and "Win32 Project" in VC++7. In 7 you then have to change the setting to DLL in the wizard.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 24th, 2003, 10:05 AM
#3
Thread Starter
Let me in ..
Originally posted by CornedBee
Yes to the second question. You can write normal C++ code, if not you couldn't write anything. The WinAPI is just an interface after all.
As for the project, it's "Win32 DLL" in VC++6 and "Win32 Project" in VC++7. In 7 you then have to change the setting to DLL in the wizard.
Can you give me some simple code to write a standard DLL.
-
Jan 24th, 2003, 05:51 PM
#4
TestDll.cpp
Code:
#define WIN32_LEAN_AND_MEAN //exclude sockets, etc from windows header
#include <windows.h>
#include <math.h> // for the square root function (sqrt)
bool APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return true; // good enough for now
}
// note that this is marked extern and _stdcall
extern bool _stdcall Quadratic(double a, double b, double c, double *result1, double *result2)
{
double tmp = (b * b) - (4 * a * c);
if (tmp < 0) return false;
*result1 = (-1 * b + sqrt(tmp)) / (2 * a);
*result2 = (-1 * b - sqrt(tmp)) / (2 * a);
return true;
}
TestDll.def
Code:
LIBRARY TestDll
EXPORTS
Quadratic @1
MyOtherFunction @2
AnotherFunction @3
to call this function from Visual Basic, you would do something like this...
VB Code:
Public Declare Function Quadratic Lib "TestDll.dll" (ByVal a As _
Double, ByVal b As Double, ByVal c As Double, ByRef result1 As _
Double, ByRef result2 As Double) As Boolean
Dim result1 As Double, result2 As Double
If Quadratic(1, 3, -12, result1, result2) Then
Call MessageBox(result1 & " " & result2)
End If
Last edited by sunburnt; Jan 24th, 2003 at 05:57 PM.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jan 25th, 2003, 09:27 AM
#5
VB Boolean and C++ bool are not the same.
VB Boolean uses 0xffffffff as true, C++ bool uses 0x00000001
Most likely it won't matter, but it might.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 25th, 2003, 02:39 PM
#6
CornedBee is right, I have had that problem before. It would be better to use a return type of int and check for 0 or !0.
You would think it wouldn't matter, but inexplicably VB seems to think that this function always returns true.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
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
|