By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

calling other languages C/C++

P: n/a
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
Oct 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Aidal wrote:
... 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.

Oct 3 '06 #2

P: n/a
Pete C skrev:
Aidal wrote:
>... 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.
Ok, thanks, I'll try there.
Oct 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.