BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling other code from C/C++

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI)
View previous topic :: View next topic  
Author Message
Aidal
Guest





PostPosted: Tue Oct 03, 2006 8:11 am    Post subject: Calling other code from C/C++ Reply with quote



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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (WinAPI) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.