Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can any one expert help me out !!!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
library MyDLL;
uses SysUtils, Classes;
function MyMin(x,y:real):real; cdecl;
begin
if x<y then Result := x else Result := y;
end;
var res : array[0..1024] of char;
function DoubleString(str:pChar):pChar; cdecl;
begin
StrCopy(res,str);
StrCat(res,str);
Result := res;
end;
exports MyMin, DoubleString;
begin
end.

This is a Delphi code DLL making layout ....... but how to do the same with C++ , can you give me this type of dll layout !

plz !!!!!
 
I haven't used Pascal in years. Instead of posting the code, can you just tell us what you're trying to do here? I think that would be received far better.

MG
 
Okay, I haven't used Pascal either, but I can see there are two functions that do something like this (no error checking to keep things simple):

int MyMin(int x, int y)
{
return ( x < y ? x : y );

// this is the same as:

// if (x < y)
// return x;
// else
// return y;
}

char* DoubleString(char* str)
{
char res[1024];

strcpy(res, str);
strcat(res, str);

return (res);
}


I believe to use these functions from a dll, you do something like this in your header file (and define the _EXPORT flag only in your DLL project):


#ifdef _EXPORT
extern &quot;C&quot; __declspec(dllexport) int MyMin(int x, int y)
extern &quot;C&quot; __declspec(dllexport) char* DoubleString(char* str);
#else
extern &quot;C&quot; __declspec(dllimport) int MyMin(int x, int y)
extern &quot;C&quot; __declspec(dllimport) char* DoubleString(char* str);
#endif
 
That code was not tested, so naturally there were at least two syntax errors, which I caught in the compiler in my head...

Be sure to add a semicolon to the end of each of the MyMin() definitions in the header file. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top