473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

calling other languages C/C++

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
2 1749
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Asapi | last post by:
1. Are linkage convention and calling convention referring to the same thing? 2. Does calling convention differ between languages C and C++? 3. How does calling convention differ between...
2
by: Tony Liu | last post by:
Hi, I want to get the name of the calling function of an executing function, I use the StackTrace class to do this and it seems working. However, does anyone think that there any side effect...
2
by: Pawan Aggarwal | last post by:
I'm having trouble with calling an exported function in a native DLL compiled with eMbedded Visual C++ in C# application in PocketPC 2002 OS. Problem Description follows: I have one exported...
2
by: Thomas Schoch | last post by:
I have a file with binary data and a dll where I have to pass a OLE_HANDLE which points to the data in the file. How do I read the data (i presume as binaryreader) and then pass the OLE_HANDLE...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.