Gamestudio Links
Zorro Links
Newest Posts
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (Quad, ozgur, Nymphodora), 7,674 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to pass a string to a DLL file? #406681
08/27/12 11:33
08/27/12 11:33
Joined: Jul 2011
Posts: 69
P
pjotr987 Offline OP
Junior Member
pjotr987  Offline OP
Junior Member
P

Joined: Jul 2011
Posts: 69
hi i try to write a function in a DLL file that should create a file with a name, that comes as string from Lite-C

here is it:

DLLFUNC int open_file(string datei_name, int status)//////////////opens file with string dateiname
{

int status;
std::string fileName(datei_name);
ifstream fin( fileName.c_str() );

if (fin.fail() )///////////////
{
//File not found

ofstream myfile;
myfile.open (datei_name);
myfile << "Writing this to a file.\n";
myfile.close();
status=1; ////////////////file created
}
else
{
status=2;///////////////file exists
}

return status;
}


now the question how to send the string(file name) from lite-c to the function?

thanks in advance

Re: how to pass a string to a DLL file? [Re: pjotr987] #406682
08/27/12 11:36
08/27/12 11:36
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

I think you can pass in a char* variable or an engine STRING *

Best regards.

Re: how to pass a string to a DLL file? [Re: 3dgs_snake] #406683
08/27/12 11:45
08/27/12 11:45
Joined: Jul 2011
Posts: 69
P
pjotr987 Offline OP
Junior Member
pjotr987  Offline OP
Junior Member
P

Joined: Jul 2011
Posts: 69
hi i tried the following way in lite-C

STRING* file_name="test.txt"; //filename
int* status;

function open_file(STRING* file_name1,int* file_status); // function declaration

then in main function

open_file(file_name,status);

but it doesnt work out.

someone has any suggestions?




Last edited by pjotr987; 08/27/12 11:45.
Re: how to pass a string to a DLL file? [Re: pjotr987] #406685
08/27/12 12:31
08/27/12 12:31
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

It is working well for me.

Code:
DLLFUNC void test_char1(STRING *str)
{
	MessageBox(NULL, _chr(str), "From DLL", MB_OK);
}

DLLFUNC void test_char2(char *str)
{
	MessageBox(NULL, str, "From DLL", MB_OK);
}



Perhaps you should use multibyte character sets in your project, and I think you can't create std::string with STRING *variables wink

Best regards.

Re: how to pass a string to a DLL file? [Re: 3dgs_snake] #406793
08/29/12 20:41
08/29/12 20:41
Joined: Jul 2011
Posts: 69
P
pjotr987 Offline OP
Junior Member
pjotr987  Offline OP
Junior Member
P

Joined: Jul 2011
Posts: 69
thanks very much. it works ! laugh


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1