int main(char argc, char **argv) { if (argc <= 1) { printf("=== PGN->XQF Convertor ===\n"); printf("Usage: PGN2XQF PGN-File [XQF-File]\n"); return 0; } PreGenInit(); ChineseInit(); switch (Pgn2Xqf(argv[1], argc == 2 ? "PGN2XQF.XQF" : argv[2])) { case PGN2XQF_ERROR_OPEN: printf("%s: File Not Found or Not a Chinese-Chess-PGN File!\n", argv[1]); break; case PGN2XQF_ERROR_CREATE: printf("File Creation Error!\n"); break; case PGN2XQF_OK: #ifdef _WIN32 if (argc == 2) { ShellExecute(NULL, NULL, "PGN2XQF.XQF", NULL, NULL, SW_SHOW); } #endif break; } return 0; }
inline void Init(void) { if (!bInit) { bInit = true; PreGenInit(); ChineseInit(); } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { char szPath[MAX_PATH], szLibEccoFile[MAX_PATH]; EccoApiStruct EccoApi; BROWSEINFO bi; LPITEMIDLIST pidl; LocatePath(szLibEccoFile, cszLibEccoFile); if (!EccoApi.Startup(szLibEccoFile)) { MessageBox(NULL, "没有找到ECCO.DLL!", "ECCO开局信息整理工具", MB_ICONEXCLAMATION); return 0; } bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = NULL; bi.lpszTitle = "请选择可移植棋谱(*.PGN)所在的文件夹"; bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = NULL; bi.iImage = 0; pidl = SHBrowseForFolder(&bi); if (SHGetPathFromIDList(pidl, szPath)) { PreGenInit(); ChineseInit(); SearchFolder(szPath, EccoApi); MessageBox(NULL, "全部棋谱已加入ECCO开局信息。", "ECCO开局信息整理工具", MB_ICONINFORMATION); } EccoApi.Shutdown(); return 0; }
int main(int argc, char **argv) { EccoApiStruct EccoApi; char szLibEccoPath[1024]; if (argc < 2) { printf("=== XQF->PGN Convertor ===\n"); printf("Usage: XQF2PGN XQF-File [PGN-File]\n"); return 0; } PreGenInit(); ChineseInit(); LocatePath(szLibEccoPath, cszLibEccoFile); EccoApi.Startup(szLibEccoPath); switch (Xqf2Pgn(argv[1], argc == 2 ? "XQF2PGN.PGN" : argv[2], EccoApi)) { case XQF2PGN_ERROR_OPEN: printf("%s: File Opening Error!\n", argv[1]); break; case XQF2PGN_ERROR_FORMAT: printf("%s: Not an XQF File!\n", argv[1]); break; case XQF2PGN_ERROR_CREATE: printf("File Creation Error!\n"); break; case XQF2PGN_OK: #ifdef _WIN32 if (argc == 2) { ShellExecute(NULL, NULL, "XQF2PGN.PGN", NULL, NULL, SW_SHOW); } #endif break; } EccoApi.Shutdown(); return 0; }
VOID WINAPI CchessInit(BOOL bTraditional) { PreGenInit(); ChineseInit(bTraditional != FALSE); }