Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Edgar_Herrera), 1,110 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
zOpen() API returns null? #483446
06/01/21 06:52
06/01/21 06:52
Joined: May 2021
Posts: 11
San Jose
H
hanw Offline OP
Newbie
hanw  Offline OP
Newbie
H

Joined: May 2021
Posts: 11
San Jose
Hi,

I am experimenting with the zInit, zData and zOpen APIs to control a zorro process.

I was able to build the zorroControl example by creating a console application in visual studio 2019 and added the source from Zorro/Source/ZorroControl to the project.

However, when running the application, the application returns "Can't initialize zorro processes"), which means this following code is failing to run.

Code
	if(!zOpen(2,"Control -run -h")) {	
		printf("Can't initialize Zorro process!"); return EXIT_FAILURE;
	}


My question is, is there an example on how to use the zOpen() API, what might be the problem?

Thanks

Re: zOpen() API returns null? [Re: hanw] #483450
06/01/21 08:07
06/01/21 08:07
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Reasons for returning 0 can be an error in the command line, a missing Zorro S license, a missing Zorro.exe, or a failed zInit call.

Re: zOpen() API returns null? [Re: hanw] #483451
06/01/21 08:38
06/01/21 08:38
Joined: May 2021
Posts: 11
San Jose
H
hanw Offline OP
Newbie
hanw  Offline OP
Newbie
H

Joined: May 2021
Posts: 11
San Jose
Thanks for the reply.

I have a Zorro S license. I am able to compile and run the Process.c program from NotePad++, I can get the zOpen api to work in C program when editing and running in Zorro GUI, but not a C++ program when editing and running from visual studio.
.
I think the zInit call is running fine, otherwise, the application would print a different error message.

Code
	if(!zInit(2,sizeof(int))) {
		printf("Can't initialize communication!"); return EXIT_FAILURE;
	}


The problem happens when I tried to build the ZorroControl cpp program. Here is the code I used. The program prints "handle=00000000"

The zInit, zData and zClose API seems to work fine. but zOpen returns 0 in the C++ program.

Code
#include "stdafx.h"
#include "ZorroControl.h"

int _tmain(int argc, _TCHAR* argv[])
{
// open ZorroControl.dll and get its function pointers
	HINSTANCE H = LoadLibrary(TEXT("ZorroControl.dll"));
	if(!H) {
		printf("Can't mount ZorroControl.dll!"); return EXIT_FAILURE;
	}
	_zInit zInit = (_zInit)GetProcAddress(H,"zInit");
	_zOpen zOpen = (_zOpen)GetProcAddress(H,"zOpen");
	_zClose zClose = (_zClose)GetProcAddress(H,"zClose");
	_zStatus zStatus = (_zStatus)GetProcAddress(H,"zStatus");
	_zData zData = (_zData)GetProcAddress(H,"zData");

// initialize process communication
	if(!zInit(2,sizeof(int))) {
		printf("Can't initialize communication!"); return EXIT_FAILURE;
	}

// get and clear the data area
	int* Info = (int*)zData(1);
	*Info = 0; 

	HANDLE open = zOpen(2, "-w 320");
	printf("handle=%p\n", open);

	// display it and quit
	printf("Zorro returned %i\n",*Info);

	zClose(2);

	Sleep(1000);
	return EXIT_SUCCESS;
}



Perhaps I'm missing something trivial. Is it related to how I loaded the ZorroControl.dll in C++ program? That seems to be the only difference between the Process.C and ZorroControl.



Attached Files zorrocontrol.PNG
Last edited by hanw; 06/01/21 09:12.
Re: zOpen() API returns null? [Re: hanw] #483457
06/01/21 10:53
06/01/21 10:53
Joined: May 2021
Posts: 11
San Jose
H
hanw Offline OP
Newbie
hanw  Offline OP
Newbie
H

Joined: May 2021
Posts: 11
San Jose
Problem solved. I need to make sure ZorroControl.exe can find zorro.exe by copying zorro.exe to the save directory that ZorroControl.exe is executed along with several other dlls.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1