int main (void) { printf ("Hello World\n"); OpenIniFile ("Test.Ini"); #ifdef INIFILE_TEST_READ_AND_WRITE WriteString ("Test", "Name", "Value"); WriteString ("Test", "Name", "OverWrittenValue"); WriteString ("Test", "Port", "COM1"); WriteString ("Test", "User", "James Brown jr."); WriteString ("Configuration", "eDriver", "MBM2.VXD"); WriteString ("Configuration", "Wrap", "LPT.VXD"); WriteInt ("IO-Port", "Com", 2); WriteBool ("IO-Port", "IsValid", 0); WriteDouble ("TheMoney", "TheMoney", 67892.00241); WriteInt ("Test" , "ToDelete", 1234); WriteIniFile ("Test.Ini"); printf ("Key ToDelete created. Check ini file. Any key to continue"); while (!kbhit()); OpenIniFile ("Test.Ini"); DeleteKey ("Test" , "ToDelete"); WriteIniFile ("Test.Ini"); #endif printf ("[Test] Name = %s\n", ReadString ("Test", "Name", "NotFound")); printf ("[Test] Port = %s\n", ReadString ("Test", "Port", "NotFound")); printf ("[Test] User = %s\n", ReadString ("Test", "User", "NotFound")); printf ("[Configuration] eDriver = %s\n", ReadString ("Configuration", "eDriver", "NotFound")); printf ("[Configuration] Wrap = %s\n", ReadString ("Configuration", "Wrap", "NotFound")); printf ("[IO-Port] Com = %d\n", ReadInt ("IO-Port", "Com", 0)); printf ("[IO-Port] IsValid = %d\n", ReadBool ("IO-Port", "IsValid", 0)); printf ("[TheMoney] TheMoney = %1.10lf\n", ReadDouble ("TheMoney", "TheMoney", 111)); CloseIniFile (); return 0; }
void LoadConfig(SystemState *LCState) { HANDLE hr=NULL; buildTransDisp2ScanTable(); LoadString(NULL, IDS_APP_TITLE,AppName, MAX_LOADSTRING); GetModuleFileName(NULL,ExecDirectory,MAX_PATH); PathRemoveFileSpec(ExecDirectory); strcpy(CurrentConfig.PathtoExe,ExecDirectory); strcpy(IniFilePath,ExecDirectory); strcat(IniFilePath,"\\"); strcat(IniFilePath,IniFileName); LCState->ScanLines=0; NumberOfSoundCards=GetSoundCardList(SoundCards); ReadIniFile(); CurrentConfig.RebootNow=0; UpdateConfig(); RefreshJoystickStatus(); SoundInit(EmuState.WindowHandle,SoundCards[CurrentConfig.SndOutDev].Guid,CurrentConfig.AudioRate); hr=CreateFile(IniFilePath,NULL,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if (hr==INVALID_HANDLE_VALUE) //No Ini File go create it WriteIniFile(); else CloseHandle(hr); }
void GetAACdecSettings ( void ) { FILE* fp = NULL; char PathAndName [] = {INI_FILE}; // set default values iniSettings.window_x = 64; // default box position (x co-ord) iniSettings.window_y = 64; // default box position (y co-ord) iniSettings.always_on_top = 8; // default = on iniSettings.logerr = 0; // default = off iniSettings.decode_mode = 1; // default = 1 (decode to file) iniSettings.outputFormat = 1; // default = 1 (16 bit PCM) iniSettings.fileType = 1; // default = 1 (Microsoft WAV) iniSettings.object_type = 1; // default = 1 (Low Complexity) // Read INI_FILE if ( (fp = fopen (PathAndName, "r")) == NULL ) { // file does not exist: write it! WriteIniFile ( PathAndName ); } else { // file does exist: read it! ReadIniFile (fp); fclose (fp); } return; }
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle uint32 fdwReason, // reason called LPVOID lpvReserved) // reserved { windowSetting.myhInst = hinstDLL; switch (fdwReason) { case DLL_PROCESS_ATTACH: InitConfiguration(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: if (bIniIsChanged) { WriteIniFile(); TRACE0("Write back INI file"); } break; } return TRUE; }
void CIniFile::SetString(CString Section, CString Item, CString Value) { //保存到FileContainer WriteFileString(Section, Item, Value); //保存到ini文件 WriteIniFile(); }
int WritePrivateProfileString(char *appNam, char *keyNam, char *keyVal, char *filNam) { while (s_read_flags) { usleep(10000); } s_read_flags = 1; if (OpenIniFile(filNam)) { char tmpBuf[CONF_MAX_PATH]; memcpy(tmpBuf, ReadString(appNam, keyNam, "NotFound"), CONF_MAX_PATH); if (!strcmp(tmpBuf, "NotFound")) { printf("set appNam=%s,keyNam=%s,NotFound\n", appNam, keyNam); CloseIniFile(); s_read_flags = 0; return 0; } else { WriteString(appNam, keyNam, keyVal); } WriteIniFile(filNam); CloseIniFile(); s_read_flags = 0; return 1; } else { s_read_flags = 0; return 0; } }
void SaveSetup( GtkWidget *parent ){ const char *name = g_FuncTable.m_pfnFileDialog( parent, false, "Save GenSurf Settings", g_FuncTable.m_pfnProfileGetDirectory(), "gtkgensurf", NULL ); if ( name != NULL ) { char key[32], text[32]; int i, j; WriteIniFile( name ); g_FuncTable.m_pfnProfileSaveString( name, OPTS_SECTION,"MapFile",gszMapFile ); sprintf( text,"0x%04x",FileAppend ); g_FuncTable.m_pfnProfileSaveString( name, OPTS_SECTION,"Append",text ); sprintf( text,"0x%04x",Decimate ); g_FuncTable.m_pfnProfileSaveString( name, OPTS_SECTION,"Decimate",text ); for ( i = 0; i <= NH; i++ ) { for ( j = 0; j <= NV; j++ ) { if ( xyz[i][j].fixed ) { sprintf( key,"I%dJ%d",i,j ); sprintf( text,"%g %g %g", xyz[i][j].fixed_value, xyz[i][j].range, xyz[i][j].rate ); g_FuncTable.m_pfnProfileSaveString( name, "FixedPoints",key,text ); } } } } }
void CIniFile::SetFloat(CString Section, CString Item, float Value) { CString strtemp; strtemp.Format(_T("%e"),Value); //保存到FileContainer WriteFileString(Section, Item, strtemp); //保存到ini文件 WriteIniFile(); }
void CTariffSetting::SaveData( ) { QStringList lstRows; QString strWhere; GetWhere( strWhere ); GetValue( lstRows ); CLogicInterface::GetInterface( )->OperateTariffInfo( lstRows, CommonDataType::UpdateData, strWhere ); WriteIniFile( ); }
/* {{{ CI_SetConfigString */ CK_DEFINE_FUNCTION(CK_RV, CI_SetConfigString)( CK_CHAR_PTR pSectionName, CK_CHAR_PTR pFieldname, CK_CHAR_PTR pValue ) { CK_RV rv = CKR_OK; bool ret; pSectionName=((pSectionName!=NULL_PTR)?pSectionName:(CK_CHAR_PTR)"PKCS11-DLL"); if(CK_I_config_fname == NULL_PTR) { rv = CKR_GENERAL_ERROR; CI_VarLogEntry("CI_GetConfigString", "Reading config field failed: config file not set", rv, 0, pFieldname, pSectionName, CK_I_config_fname, CK_I_init_fail_reasons[rv]); return rv; } do { ret = OpenIniFile(CK_I_config_fname); if (ret != TRUE) break; ret = DeleteKey(pSectionName, pFieldname); if (ret != TRUE) { CloseIniFile(); break; } WriteString(pSectionName, pFieldname, pValue); WriteIniFile(CK_I_config_fname); }while (false); if(ret != TRUE) { CI_VarLogEntry("CI_SetConfigString", "Setting config field '%s' from section [%s] in file '%s' failed: %s", CKR_GENERAL_ERROR, 0, pFieldname, pSectionName, CK_I_config_fname, CK_I_init_fail_reasons[rv]); return CKR_GENERAL_ERROR; } return CKR_OK; }
void SaveConfigurationToFile( void ) { TYPE_File *writeFile = NULL; int i = 0; char str[256]; dataBuffer_ini = TAP_MemAlloc( DATA_BUFFER_SIZE_ini ); // Buffer the write data to memory before writing all in one hit memset( dataBuffer_ini, '\0', DATA_BUFFER_SIZE_ini ); // set the whole buffer to the string termination character (null) dataBufferPtr_ini = 0; switch ( unitModelType ) { case TF5800 : TAP_SPrint(str, "TF5800\r\n" ); break; case TF5000 : TAP_SPrint(str, "TF5000\r\n" ); break; default : TAP_SPrint(str, "BAD\r\n" ); break; } WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", mainActivationKey ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchMode ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchTime ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", FirmwareCallsEnabled ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainTRCEnabled ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainPerformSearchDays ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainDateFormat ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainTimeFormat ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", keyboardLanguage ); WriteStrToIniBuf( str ); TAP_SPrint(str, "%d\r\n", schMainConflictOption ); WriteStrToIniBuf( str ); WriteIniFile( writeFile ); // write all the data in one pass TAP_MemFree( dataBuffer_ini ); // must return the memory back to the heap }
void __stdcall IDAP_run(int arg) { //msg("IDAP_run arg: %d \ng_Index:%d \ng_Path :%s\n", arg, g_Index, g_szIniPath); // 插件的实体 //在LOG中显示一个字符串 msg("============开始复制字符串==============\n"); uval_t nAddres = get_screen_ea(); int i = 0; int j = 0; UINT32 size = 0; int nCover = 0; USHORT checkmask = 0; char *lpBuf = (char *)malloc(0x1000); memset(lpBuf, 0, 0x1000); if (GetAsyncKeyState(VK_SHIFT) & 0x8000) { if(AskUsingForm_c(dialog, &nAddres, &g_Index, &g_CheckClip) == 1) { WriteIniFile(); if(!isLoaded(nAddres)) { msg("地址无效!读取数据失败!\n"); return; } else { size = ReadString(nAddres, lpBuf); } } } else { size = ReadString(get_screen_ea(), lpBuf); } if(g_CheckClip && size) { msg("已将结果发送至送剪切板!\n"); SnedClipData(lpBuf, size); } msg("使用%s编码打印字符串:\n%s\n", g_CodeTable[g_Index], lpBuf); free(lpBuf); return; }
m64p_error ricePluginShutdown(void) { if (!l_PluginInit) return M64ERR_NOT_INIT; if( status.bGameIsRunning ) { riceRomClosed(); } #if 0 if (bIniIsChanged) { WriteIniFile(); TRACE0("Write back INI file"); } #endif /* reset some local variables */ l_DebugCallback = NULL; l_DebugCallContext = NULL; l_PluginInit = 0; return M64ERR_SUCCESS; }
/************************************************************************** * * FUNCTION NAME: ProcessRegisterDialog * * DESCRIPTION: * * * INPUT PARAMETERS: * None. * * OUTPUT PARAMETERS: * None. * **************************************************************************/ MRESULT EXPENTRY ProcessRegisterDialog (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { CHAR szID[50]; switch (msg) { case WM_INITDLG : /* Center the dialog box in the frame window of the parent */ CenterDialog (hwnd); return (0); case WM_COMMAND : switch (SHORT1FROMMP (mp1)) { case DID_OK: WinQueryDlgItemText (hwnd, REG_NAME_ID, REGISTER_NAME_LEN, gszRegName); WinQueryDlgItemText (hwnd, REG_ID_ID, sizeof(szID), szID); if (CheckPassword (gszRegName, szID)) { /* The password is cool! Save the settings now */ WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, CONGRATS_DLG_ID, NULL); gfRegistered = TRUE; WriteIniFile (); /* Disable the register menu item now we're registered */ WinEnableMenuItem (hwndMenu, MENU_REGISTER_ID, !gfRegistered); WinDismissDlg (hwnd, DID_OK); } else { WinDlgBox (HWND_DESKTOP, hwndDefClient, (PFNWP) ProcessProdInfoDialog, 0L, SORRY_DLG_ID, NULL); } return (0); case DID_CANCEL: /* Dismiss the dialog without saving the values */ WinDismissDlg (hwnd, DID_CANCEL); return (0); case DID_HELP: /* Display the keys help panel */ WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT(PANEL_REGISTER, NULL), MPFROMSHORT(HM_RESOURCEID)); return (0); default: break; } break; default: break; } return (WinDefDlgProc (hwnd, msg, mp1, mp2)); }
///----------------------------------------------------------------------------- void DeleteIniFile(void){ WriteIniFile(); delete(MainIniStruct); }
void CloseWriteFile(char *filNam) { WriteIniFile(filNam); CloseTypeFile(); }
/*--------------------------------------------------------------------------*/ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG Msg; EmuState.WindowInstance = hInstance; char temp1[MAX_PATH]=""; char temp2[MAX_PATH]=" Running on "; unsigned threadID; HANDLE hEvent, // SetPriorityClass(GetCurrentProcess(),ABOVE_NORMAL_PRIORITY_CLASS ); // SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL); // CoInitializeEx(NULL,COINIT_MULTITHREADED); // CoInitialize(NULL); // InitializeCriticalSection(); OleInitialize(NULL); //Work around fixs app crashing in "Open file" system dialogs (related to Adobe acrobat 7+ LoadString(hInstance, IDS_APP_TITLE,g_szAppName, MAX_LOADSTRING); if ( strlen(lpCmdLine) !=0) { strcpy(QuickLoadFile,lpCmdLine); strcpy(temp1,lpCmdLine); PathStripPath(temp1); strlwr(temp1); temp1[0]=toupper(temp1[0]); strcat (temp1,temp2); strcat(temp1,g_szAppName); strcpy(g_szAppName,temp1); } EmuState.WindowSize.x=640; EmuState.WindowSize.y=480; InitInstance (hInstance, nCmdShow); if (!CreateDDWindow(&EmuState)) { MessageBox(0,"Can't create primary Window","Error",0); exit(0); } Cls(0,&EmuState); DynamicMenuCallback( "",0, 0); DynamicMenuCallback( "",1, 0); LoadConfig(&EmuState); //Loads the default config file Vcc.ini from the exec directory EmuState.ResetPending=2; SetClockSpeed(1); //Default clock speed .89 MHZ BinaryRunning = true; EmuState.EmulationRunning=AutoStart; if (strlen(lpCmdLine)!=0) { Qflag=255; EmuState.EmulationRunning=1; } hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ) ; if (hEvent==NULL) { MessageBox(0,"Can't create Thread!!","Error",0); return(0); } hEMUThread = (HANDLE)_beginthreadex( NULL, 0, &EmuLoop, hEvent, 0, &threadID ); if (hEMUThread==NULL) { MessageBox(0,"Can't Start main Emulation Thread!","Ok",0); return(0); } WaitForSingleObject( hEvent, INFINITE ); SetThreadPriority(hEMUThread,THREAD_PRIORITY_NORMAL); // InitializeCriticalSection(&FrameRender); while (BinaryRunning) { if (FlagEmuStop==TH_WAITING) //Need to stop the EMU thread for screen mode change { //As it holds the Secondary screen buffer open while running FullScreenToggle(); FlagEmuStop=TH_RUNNING; } GetMessage(&Msg,NULL,0,0); //Seems if the main loop stops polling for Messages the child threads stall TranslateMessage(&Msg); DispatchMessage(&Msg) ; } CloseHandle( hEvent ) ; CloseHandle( hEMUThread ) ; timeEndPeriod(1); UnloadDll(); SoundDeInit(); WriteIniFile(); //Save Any changes to ini File return Msg.wParam; }
void __stdcall IDAP_term(void) { //当结束插件时,一般您可以在此添加一点任务清理的代码。 WriteIniFile(); return; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc, hmem; static HDC offscreen; PAINTSTRUCT ps; RECT rect, rect2; BITMAP bm; POINT point; static POINT start; static int dragging = 0; HDC desktop; HBITMAP hbitmap; HANDLE hdrop; HFONT dfltFont; int dfltBGMode; double percomp; switch (message) { case WM_CREATE: menu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1)); menu = GetSubMenu(menu, 0); offscreen = CreateCompatibleDC(NULL); desktop = GetDC(GetDesktopWindow()); hbitmap = CreateCompatibleBitmap(desktop, 200, 200); ReleaseDC(GetDesktopWindow(), desktop); SelectObject(offscreen, hbitmap); // Start the engines decthread_init(); // We accept drag&drop DragAcceptFiles(hwnd, TRUE); return 0; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); width = rect.right + 1; height = rect.bottom + 1; FillRect(offscreen, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); DrawText(offscreen, "Drop Files Here", -1, &rect, DT_SINGLELINE | DT_CENTER); SetRect(&rect2, 0, height - 110, width, height - 25); DrawText(offscreen, "For Decoding", -1, &rect2, DT_SINGLELINE | DT_CENTER); hmem = CreateCompatibleDC(offscreen); SelectObject(hmem, hbm[frame]); GetObject(hbm[frame], sizeof(BITMAP), &bm); BitBlt(offscreen, width / 2 - 33, height / 2 - 31, bm.bmWidth, bm.bmHeight, hmem, 0, 0, SRCCOPY); DeleteDC(hmem); percomp = ((double)(totalfiles - numfiles) + 1 - (1 - file_complete)) / (double)totalfiles; SetRect(&vbrBR, 0, height - 35, width, height - 19); dfltBGMode = SetBkMode(offscreen, TRANSPARENT); dfltFont = SelectObject(offscreen, font2); SetRect(&bar1, 0, height - 23, (int)(file_complete * width), height - 13); SetRect(&bar2, 0, height - 12, (int)(percomp * width), height - 2); FillRect(offscreen, &bar1, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); FillRect(offscreen, &bar2, (HBRUSH)GetStockObject(DKGRAY_BRUSH)); if (fileName) { char* sep; char fileCaption[80]; if ((sep = strrchr(fileName, '\\')) != 0) fileName = sep+1; (void) strcpy(fileCaption, " "); (void) strcat(fileCaption, fileName); DrawText(offscreen, fileCaption, -1, &bar1, DT_SINGLELINE | DT_LEFT); } SelectObject(offscreen, dfltFont); SetBkMode(offscreen, dfltBGMode); BitBlt(hdc, 0, 0, width, height, offscreen, 0, 0, SRCCOPY); EndPaint(hwnd, &ps); return DefWindowProc(hwnd, message, wParam, lParam); //return 0; case WM_TIMER: if (animate || frame) { frame++; if (frame > 7) frame -= 8; } else { frame = 0; } GetClientRect(hwnd, &rect); InvalidateRect(hwnd, &rect, FALSE); return 0; case WM_LBUTTONDOWN: start.x = LOWORD(lParam); start.y = HIWORD(lParam); ClientToScreen(hwnd, &start); GetWindowRect(hwnd, &rect); start.x -= rect.left; start.y -= rect.top; dragging = 1; SetCapture(hwnd); return 0; case WM_LBUTTONUP: if (dragging) { dragging = 0; ReleaseCapture(); } return 0; case WM_MOUSEMOVE: if (dragging) { point.x = LOSHORT(lParam); point.y = HISHORT(lParam); /* lParam can contain negative coordinates ! * point.x = LOWORD(lParam); * point.y = HIWORD(lParam); */ ClientToScreen(hwnd, &point); SetWindowPos(hwnd, 0, point.x - start.x, point.y - start.y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); iniSettings.window_x = point.x - start.x; iniSettings.window_y = point.y - start.y; } return 0; case WM_CAPTURECHANGED: if (dragging) { dragging = 0; ReleaseCapture(); } return 0; case WM_RBUTTONUP: point.x = LOWORD(lParam); point.y = HIWORD(lParam); ClientToScreen(hwnd, &point); TrackPopupMenu(menu, TPM_RIGHTBUTTON, point.x, point.y, 0, hwnd, NULL); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_QUIT: WriteIniFile(INI_FILE); decoding_done = 1; PostQuitMessage(0); break; case IDM_ONTOP: set_always_on_top(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); break; case IDM_LOGERR: set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED); break; case IDM_STOP_DEC: { int v = ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED; if(v == 8) stop_decoding = 1; break; } case IDM_VOLUME: { int value = DialogBox( hinst, MAKEINTRESOURCE(IDD_VOLUME), hwnd, QCProc); if (value == -2) break; break; } case IDM_ABOUT: { int value = DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUT), hwnd, QCProc); if (value == -7) break; break; } } // LOWORD(wParam) return 0; case WM_DROPFILES: hdrop = (HANDLE)wParam; HandleDrag(hwnd, hdrop); return 0; case WM_DESTROY: decoding_done = 1; PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }