#include #include "stringutils.h" extern "C" int main(int, char**); WINBASEAPI HANDLE WINAPI CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { return CreateFileW(ToWString(lpFileName).c_str(), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } WINBASEAPI HMODULE WINAPI GetModuleHandleA(LPCSTR lpModuleName) { return GetModuleHandleW(ToWString(lpModuleName).c_str()); } WINBASEAPI DWORD WINAPI FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, va_list *Arguments) { std::wstring buf; buf.resize(nSize); DWORD res= FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, &buf[0], nSize, Arguments); strncpy(lpBuffer, ToString(buf).c_str(), nSize); return res; } _CRTIMP struct tm * __cdecl gmtime(const time_t *t) { TIME_ZONE_INFORMATION tz; DWORD id= GetTimeZoneInformation(&tz); if (id==TIME_ZONE_ID_INVALID) return NULL; time_t tlocal = *t - 60 * tz.Bias; return localtime(&tlocal); } _CRTIMP struct tm * __cdecl localtime(const time_t *t) { static struct tm tm; SYSTEMTIME ts; GetLocalTime(&ts); tm.tm_year= ts.wYear-1900; tm.tm_mon= ts.wMonth-1; tm.tm_mday= ts.wDay; tm.tm_hour= ts.wHour; tm.tm_min= ts.wMinute; tm.tm_sec= ts.wSecond; tm.tm_wday= ts.wDayOfWeek; tm.tm_yday= 0; // todo - calc yday TIME_ZONE_INFORMATION tz; DWORD id= GetTimeZoneInformation(&tz); tm.tm_isdst= id==TIME_ZONE_ID_DAYLIGHT; return &tm; } #ifdef _AA_WITH_WINMAIN int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { StringList args; if (!SplitString(ToString(lpCmdLine), args, true)) { args.push_back(ToString(lpCmdLine)); } std::vector argv; argv.resize(args.size()+2); WCHAR appname[MAX_PATH]; if (!GetModuleFileName(NULL, appname, MAX_PATH)) appname[0]=0; std::string app= ToString(appname); argv[0]= &app[0]; for (unsigned i=0 ; i