calling other languages C/C++

A

Aidal

Hi NG.

I have this predefined example of a tiny test dll, that does nothing but
define the 2 functions STR2LOWER and STR2UPPER.

I was told that the example was written in Borland C++Builder 4.5 some
years back, but never the less, the code is still in use today it seems.

I myself, code in C# and I haven't looked at any C/C++ in several years
and I don't remember much of it.

I have a few questions that somone using these languages on a daily
basis probably can answer without breaking a sweat.

1) is it possible to make a dll like this one, use another dll i.e. a
C#.NET one?

2) if this is the case, how do one handle the return values of what
would be C#-string -> C/C++ char* ?

If anyone can give me an answer to any of this, it would be great with
some examples, since I'm (as stated above) very rusty in these languages.

This test dll is supposed to be called from within another application
by the way, not from another language.

Below is the dll example:
--------------------------------------------------- START
#include <windows.h>
#include <stdlib.h>

char *buffer = 0;
const int STRMAX = 255;

BOOL WINAPI DllEntryPoint(HINSTANCE hinstDll, DWORD fdwRreason, LPVOID
plvReserved)
{
switch (fdwRreason)
{
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
return 1;

case DLL_PROCESS_ATTACH:
// Put initialization code here (Run the first time DllOpen
is called)
// for each process
buffer = (char*)malloc(STRMAX* sizeof(char));
if( NULL == buffer )
return 0;
else
return 1;

case DLL_PROCESS_DETACH:
free(buffer);
return 1 ;
}
return 0;
}

#ifdef __cplusplus
extern "C" {
char* FAR PASCAL _export STR2LOWER (long, unsigned char*);
char* FAR PASCAL _export STR2UPPER (long, unsigned char*);
}
#endif

char* FAR PASCAL _export STR2UPPER(long dummy, char* argument)
{
return strcpy( buffer, AnsiUpper(argument));
}

char* FAR PASCAL _export STR2LOWER(long dummy, char* argument)
{
return strcpy( buffer, AnsiLower(argument));
}
--------------------------------------------------- END

Any help would be much appreciated :)

/Aidal
 
P

Pete C

Aidal said:
... test dll ... C#.NET ... C#-string ...

Hi Aidal,
your questions are highly platform-specific, and don't relate to the
C++ language itself. You'll get better answers if you ask in the
comp.os.ms-windows.programmer.* set of newsgroups.
 
A

Aidal

Pete C skrev:
Hi Aidal,
your questions are highly platform-specific, and don't relate to the
C++ language itself. You'll get better answers if you ask in the
comp.os.ms-windows.programmer.* set of newsgroups.
Ok, thanks, I'll try there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top