Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, AndrewAMD), 722 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
using the Windows API #428087
08/17/13 18:08
08/17/13 18:08
Joined: Apr 2013
Posts: 57
3
3DCat Offline OP
Junior Member
3DCat  Offline OP
Junior Member
3

Joined: Apr 2013
Posts: 57
Hi,
since I'm a noob at programming, i got stuck trying to write a script that shall eventually convert CSV pricedata to BAR Files.
I got stuck right at the beginning where i want to convert normal Timestamps/Date to OLE format. I try to use the WindowsAPI
Quote:

#include <default.c>
#include <stdio.h>
#include <windows.h>

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;


void main()
{
int WINAPI SystemTimeToVariantTime(SYSTEMTIME* lpSystemTime, double* pvtime);
int WINAPI VariantTimeToSystemTime(double* pvtime, SYSTEMTIME* lpSystemTime);

SYSTEMTIME st,lt,xt;
double vtime;

GetSystemTime(&st);
GetLocalTime(&lt);

printf("The system time is: %02d:%02d",st.wHour, st.wMinute);
printf("\n");
printf("The local time is: %02d:%02d", lt.wHour, lt.wMinute);
printf("\n");

SystemTimeToVariantTime(&st,&vtime);

printf("VariantTime is: %02f",vtime);
printf("\n");

VariantTimeToSystemTime(&vtime,&xt);

printf("Reconverted Time is: %02d:%02d",xt.wHour,xt.wMinute);
printf("\n");
}


I can't seem to get the SystemTimeToVariantTime right. It produces an error all the time.
Any hints would be nice. I suspected the Struct to be wrong, or some pointer wrongly initialized, but I'm new to programming, especially windowsAPI creeps me out:)

Re: using the Windows API [Re: 3DCat] #428089
08/17/13 18:30
08/17/13 18:30
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
The VariantTimeToSystemTime does not alter the variant time and gets a double, not a double pointer. Also I think you must declare API functions globally, not inside the main function.

Re: using the Windows API [Re: Petra] #428112
08/18/13 07:52
08/18/13 07:52
Joined: Apr 2013
Posts: 57
3
3DCat Offline OP
Junior Member
3DCat  Offline OP
Junior Member
3

Joined: Apr 2013
Posts: 57
You're a genius! It works!
cool
Thanks


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1