Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 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 | chip programmers | 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