BOOL LocalAddPortEx( LPWSTR pName, DWORD Level, LPBYTE pBuffer, LPWSTR pMonitorName ) { LPWSTR pPortName; DWORD Error; WCHAR szLocalMonitor[MAX_PATH+1]; LPPORT_INFO_1 pPortInfo1; LPPORT_INFO_FF pPortInfoFF; LoadString(hInst, IDS_LOCALMONITOR, szLocalMonitor, sizeof(szLocalMonitor)-1); if (IS_NOT_LOCAL_PORT( pMonitorName, szLocalMonitor)) { // If pMonitorName != "Local Port", we have an // invalid Monitor name SetLastError(ERROR_INVALID_PARAMETER); return(FALSE); } switch (Level) { case (DWORD)-1: pPortInfoFF = (LPPORT_INFO_FF)pBuffer; pPortName = pPortInfoFF->pName; break; case 1: pPortInfo1 = (LPPORT_INFO_1)pBuffer; pPortName = pPortInfo1->pName; break; default: SetLastError(ERROR_INVALID_LEVEL); return(FALSE); } if (!pPortName) { SetLastError(ERROR_INVALID_PARAMETER); return(FALSE); } if (PortExists(pName, pPortName, &Error)) { SetLastError(ERROR_INVALID_PARAMETER); return(FALSE); } if (Error != NO_ERROR) { SetLastError(Error); return(FALSE); } if (!CreatePortEntry(pPortName)) { return(FALSE); } if (!WriteProfileString(szPorts, pPortName, L"")) { DeletePortEntry(pPortName); return(FALSE); } return TRUE; }
BOOL FWriteIniString(INT idsTopic, INT idsItem, TCHAR *szValue) { TCHAR szItem[32]; TCHAR szTopic[32]; CchString(szTopic, idsTopic); CchString(szItem, idsItem); return WriteProfileString(szTopic, szItem, szValue); }
void CDfuToolApp::SaveParam() { int i; TCHAR ss[MAX_PATH]; for(i=0;i<MAX_UPDATE_NUM;i++) { _stprintf(ss,_T("UpdateFile%d"),i+1); WriteProfileString(_T("SysSet"),ss,m_strUpdateFile[i]); } // ::WritePrivateProfileString("SysSet","ImportDir",m_strImportDir,m_strINIFile); }
void Profile::Reset ( ) { #ifdef __OS2__ PrfWriteProfileData ( Handle, PSZ(Name), 0, 0, 0 ) ; #else // __NT__ if ( ProfileName[0] ) { WritePrivateProfileString ( Name, 0, 0, ProfileName ) ; } else { WriteProfileString ( Name, 0, 0 ) ; } /* endif */ #endif // __OS2__ vs __NT__ } /* endmethod */
/** write value in a specific ini file */ long FileIO::FileIni::WriteInt(char * cSection, char * Key, int /*iReadValue*/) { #ifdef _WINDOWS WriteProfileString( (LPCTSTR)cSection, (LPCTSTR)Key, (LPCTSTR)("33") ); //int iError = GetLastError(); #endif return FILE_SUCCESS; }
int FAR PASCAL LibMain(HINSTANCE hInstance, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine) { OFSTRUCT ofStruct ; int fh ; BOOL fLoadNetware = FALSE ; char IsInstalledString[16] ; UNREFERENCED(hInstance) ; UNREFERENCED(wDataSeg) ; UNREFERENCED(cbHeapSize) ; UNREFERENCED(lpszCmdLine) ; I_SetCapBits() ; if (GetProfileString("NWCS", "NwcsInstalled", "0", IsInstalledString, sizeof(IsInstalledString))) { fLoadNetware = (lstrcmp("1",IsInstalledString)==0) ; } // // if enhanced mode, grab the interrupt for NWIPXSPX // if ((GetWinFlags() & WF_ENHANCED) && fLoadNetware) { GrabInterrupts(); } // // if the file NETWARE.DRV exists, we load it. we dont really // use it, but some Netware aware apps require that it is loaded. // if (fLoadNetware && ((fh = OpenFile(NETWARE_DLL, &ofStruct, OF_READ)) != -1)) { _lclose(fh) ; (void)WriteProfileString("Windows", "NetWarn", "0") ; (void)LoadLibrary(NETWARE_DLL) ; } return 1 ; }
void CRegistry::SaveTransferParam(TransferParam tp, CString pszKey) { CCrypto crypt; CString csPassword; if (Create(pszKey) == ERROR_SUCCESS) { //Uploader & Media WriteProfileInt(_T("Service"), tp.iService); WriteProfileString(_T("Server"), tp.csServer); WriteProfileInt(_T("Port"), tp.nPort); WriteProfileString(_T("Username"), tp.csUsername); WriteProfileInt(_T("SavePassword"), tp.bSavePassword); if (tp.bSavePassword) { csPassword = crypt.Encode(tp.csPassword); WriteProfileString(_T("Password"), csPassword); } else { csPassword.Empty(); WriteProfileString(_T("Password"), csPassword); } WriteProfileString(_T("Directory"), tp.csDirectory); Close(); } }
BOOL Bomb( HINSTANCE hInstance ) /************************************************************************/ { #ifdef _MAC return FALSE; #endif FNAME sz; BOOL bDisable, bPutDay1, bPutDay2; int iDay, iDay1, iDay2, iDaysInstalled; STRING szMessage; GetModuleFileName( hInstance, sz, sizeof(sz)-1); if ( !IsDemo( sz ) ) return( NO ); iDay = day(); iDay1 = GetProfileInt( "windows", "DeviceID", -1 ); iDay2 = GetDefaultInt( "DeviceID", -1 ); bPutDay1 = (iDay1 < 0); // If they can't be found, we'll write them out bPutDay2 = (iDay2 < 0); if ( bPutDay1 && bPutDay2 ) // First time running iDay1 = iDay2 = iDay; else if ( bPutDay1 ) // Windows was reinstalled (or different version) iDay1 = iDay2; else if ( bPutDay2 ) // PP was reinstalled iDay2 = iDay1; if ( bPutDay1 ) WriteProfileString( "windows", "DeviceID", itoa(iDay1,sz,10) ); if ( bPutDay2 ) PutDefaultInt( "DeviceID", iDay2 ); iDaysInstalled = iDay - min( iDay1, iDay2 ); if ( bDisable = (iDaysInstalled < 0 || iDaysInstalled >= 30) ) lstrcpy( szMessage, "\tTHIS COPY HAS EXPIRED" ); else wsprintf( szMessage, "You have %d days before this copy expires", 30 - iDaysInstalled ); Print( "Thank you for trying out this 30 day working copy of Crayola software.\n\n%ls.\n\nTo order your full version, use the enclosed offer card or call:\n\n\tUSA, Canada\t1-800-598-1930\n\tUnited Kingdom\t(+44) 0 483 747526\n\tScandanavia\t(+45) 43 43 26 77\n\tFrance\t\t(+33) 1 69 18 19 50\n\tGermany\t\t(+49) 089 260 3830\n\tAustralia/N.Z.\t(+61) 2 415 2642\n\tOthers call USA\t1-214-234-1769\n\t\t(rotary)\t1-214-234-6018", (LPSTR)szMessage ); return( bDisable ); }
BOOL PutDefaultString( LPSTR lpKeyName, LPSTR lpString) /************************************************************************/ { LPSTR lp; #ifdef PRIVATE_INI if ( !szPreferenceFile[0] ) { if ( !AstralStr( IDS_INIFILE, &lp ) ) lp = PRIVATE_INI; lstrcpy( szPreferenceFile, lp ); GetIniPath( szPreferenceFile ); } return( WritePrivateProfileString( ID_APPL, stripstruct(lpKeyName), lpString, szPreferenceFile )); #else return( WriteProfileString( ID_APPL, stripstruct(lpKeyName), lpString )); #endif }
BOOL Profile::PutItem ( char *ItemName, void *Item, int Size ) { if ( !IsReady() ) return ( FALSE ) ; #ifdef __OS2__ if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, Size ) ) { char Message [512] ; Log ( "Profile::PutItem: Could not put INI item. App %s, Item %s, size %i. %s", Name, ItemName, Size, InterpretWinError(0,Message) ) ; return ( FALSE ) ; } /* endif */ #else // __NT__ char *Buffer = new char [Size*2+1] ; if ( Buffer ) { for ( int i=0; i<Size; i++ ) sprintf ( &Buffer[i*2], "%02X", ((unsigned char*)Item)[i] ) ; if ( ProfileName[0] ) { if ( !WritePrivateProfileString ( Name, ItemName, Buffer, ProfileName ) ) { char Message [512] ; Log ( "Profile::PutString: Could not put INI item. App %s, Item %s, Value %s. %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ; return ( FALSE ) ; } /* endif */ } else { if ( !WriteProfileString ( Name, ItemName, Buffer ) ) { char Message [512] ; Log ( "Profile::PutString: Could not put INI item. App %s, Item %s, Value %s. %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ; return ( FALSE ) ; } /* endif */ } /* endif */ delete [] Buffer ; } else { Log ( "Profile::PutItem: Could not put INI item. App %s, Item %s, size %i. Insufficient memory.", Name, ItemName, Size ) ; return ( FALSE ) ; } /* endif */ #endif // __OS2__ vs __NT__ return ( TRUE ) ; } /* endmethod */
VOID NEAR PASCAL WriteProfileInt(WORD wAppName, WORD wKey, int nVal) { HANDLE hAppName, hKey; char buf[10]; if(!(hAppName=MyLoadString(wAppName, NULL, LMEM_MOVEABLE))) goto Error1; if(!(hKey=MyLoadString(wKey, NULL, LMEM_MOVEABLE))) goto Error2; wsprintf(buf, "%d", nVal); WriteProfileString(LocalLock(hAppName), LocalLock(hKey), buf); LocalUnlock(hKey); LocalUnlock(hAppName); Error2: LocalFree(hKey); Error1: LocalFree(hAppName); }
void CHMMDemoApp::SaveSettings() { //****************Save Settings into registry)*************************************/ CString states_string; //write number of states states_string.Format("%d", m_dlgHMMParams->m_States[0] ); for( int i = 0 ; i < m_dlgHMMParams->m_States[0] ; i++ ) { CString add; add.Format(" %d", m_dlgHMMParams->m_States[ i + 1 ] ); states_string+= add; } //write number of HMM states WriteProfileString( "Settings\\HMM", "NumStates", states_string ); //write number of mixtures WriteProfileInt("Settings\\HMM", "NumMix", m_dlgHMMParams->m_NumMix ); //write sampling parameters (dctSize, obsSize, delta) WriteProfileInt("Settings\\Sampling", "WindowWidth" , m_dlgSamplingParams->m_dctSize.width ); WriteProfileInt("Settings\\Sampling", "WindowHeight", m_dlgSamplingParams->m_dctSize.height ); WriteProfileInt("Settings\\Sampling", "DCTCoeffX", m_dlgSamplingParams->m_obsSize.width ); WriteProfileInt("Settings\\Sampling", "DCTCoeffY", m_dlgSamplingParams->m_obsSize.height ); WriteProfileInt("Settings\\Sampling", "DeltaX", m_dlgSamplingParams->m_delta.width ); WriteProfileInt("Settings\\Sampling", "DeltaY", m_dlgSamplingParams->m_delta.height ); //*******************************End saving Settings *************************************/ //write scaling params WriteProfileInt("Settings\\Scaling", "UseFixedWidth" , m_dlgMiscParams->m_useWidth ); WriteProfileInt("Settings\\Scaling", "FixedWidth", m_dlgMiscParams->m_FixedWidth ); WriteProfileInt("Settings\\Scaling", "UseFixedHeight", m_dlgMiscParams->m_useHeight); WriteProfileInt("Settings\\Scaling", "FixedHeight", m_dlgMiscParams->m_FixedHeight ); WriteProfileInt("Settings\\Scaling", "SuppressIntensity", m_dlgMiscParams->m_SuppressIntensity ); }
BOOL DeletePort( LPWSTR pName, HWND hWnd, LPWSTR pPortName ) { BOOL rc; if( !hWnd ) hWnd = GetDesktopWindow( ); EnterSplSem(); if (rc = DeletePortEntry( pPortName )) WriteProfileString(szPorts, pPortName, NULL); LeaveSplSem(); return rc; UNREFERENCED_PARAMETER( pName ); }
BOOL CXTPRegistryManager::WriteProfileDouble(LPCTSTR lpszSection, LPCTSTR lpszEntry, double* pValue) { ASSERT(lpszSection != NULL); if (m_strINIFileName.IsEmpty()) { CHKey hSecKey(GetSectionKey(lpszSection)); if (hSecKey == NULL) return FALSE; m_lResult = ::RegSetValueEx(hSecKey, lpszEntry, NULL, REG_BINARY, (LPBYTE)pValue, sizeof(*pValue)); if (m_lResult != ERROR_SUCCESS) return FALSE; return TRUE; } LPBYTE pData = (LPBYTE) pValue; UINT nBytes = sizeof(double); LPTSTR lpsz = new TCHAR[nBytes * 2 + 1]; UINT i; for (i = 0; i < nBytes; i++) { lpsz[i * 2] = (TCHAR)((pData[i] & 0x0F) + 'A'); //low nibble lpsz[i * 2 + 1] = (TCHAR)(((pData[i] >> 4) & 0x0F) + 'A'); //high nibble } lpsz[i * 2] = 0; ASSERT(m_strINIFileName.IsEmpty() == FALSE); BOOL bResult = WriteProfileString(lpszSection, lpszEntry, lpsz); delete[] lpsz; return bResult; }
BOOL CXTPRegistryManager::WriteProfileSize(LPCTSTR lpszSection, LPCTSTR lpszEntry, CSize* pValue) { ASSERT(lpszSection != NULL); if (m_strINIFileName.IsEmpty()) { CHKey hSecKey(GetSectionKey(lpszSection)); if (hSecKey == NULL) return FALSE; m_lResult = ::RegSetValueEx(hSecKey, lpszEntry, NULL, REG_BINARY, (LPBYTE)pValue, sizeof(CSize)); if (m_lResult != ERROR_SUCCESS) return FALSE; return TRUE; } CString str; str.Format(_T("%i,%i"), pValue->cx, pValue->cy); BOOL bResult = WriteProfileString(lpszSection, lpszEntry, str); return bResult; }
void CRegistry::SaveMediaTransferParam(TransferParam &tp, CString pszKey) { CCrypto crypt; CString csPassword; if (Open(pszKey) == ERROR_SUCCESS) { WriteProfileInt(_T("Media Service"), tp.iService); WriteProfileString(_T("Media Server"), tp.csServer); WriteProfileInt(_T("Media Port"), tp.nPort); WriteProfileString(_T("Media Username"), tp.csUsername); WriteProfileInt(_T("Media SavePassword"), tp.bSavePassword); if (tp.bSavePassword) { csPassword = crypt.Encode(tp.csPassword); WriteProfileString(_T("Media Password"), csPassword); } else { csPassword.Empty(); WriteProfileString(_T("Media Password"), csPassword); } WriteProfileString(_T("Media Directory"), tp.csDirectory); WriteProfileString(_T("Media URL"), tp.csUrl); Close(); } }
void CRegistry::SaveChannelTransferParam(TransferParam tp, CString pszKey) { CCrypto crypt; CString csPassword; if (Create(pszKey) == ERROR_SUCCESS) { WriteProfileInt(_T("Channel Service"), tp.iService); WriteProfileString(_T("Channel Server"), tp.csServer); WriteProfileInt(_T("Channel Port"), tp.nPort); WriteProfileString(_T("Channel Username"), tp.csUsername); WriteProfileInt(_T("Channel SavePassword"), tp.bSavePassword); if (tp.bSavePassword) { csPassword = crypt.Encode(tp.csPassword); WriteProfileString(_T("Channel Password"), csPassword); } else { csPassword.Empty(); WriteProfileString(_T("Channel Password"), csPassword); } WriteProfileString(_T("Channel Directory"), tp.csDirectory); WriteProfileString(_T("Channel URL"), tp.csUrl); Close(); } }
BOOL CGalileoApp::InitInstance() { char iometer_path[MAX_PATH]; char *p; test_state = TestIdle; login_state = closed; // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #if _MSC_VER < 1300 #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif //init file version strings GetAppFileVersionString(&m_pVersionString, &m_pVersionStringWithDebug); SetRegistryKey( "Intel" ); // Stores information in the registry under // HKEY_CURRENT_USER\Software\Intel. LoadStdProfileSettings(); // Load standard INI file options (including MRU) // // Check to see if the end user license agreement should be displayed. // If the current version is not stored in the registry, disply the EULA. // #ifndef _DEBUG if ( GetProfileString( "Settings", "Version" ) != m_pVersionString ) { CLegalBox legalDlg; // Display EULA. if ( legalDlg.DoModal() == IDOK ) // User agrees to terms, so store the version in the registry. WriteProfileString( "Settings", "Version", m_pVersionString ); else return FALSE; // User does not agree to terms so exit. } #endif // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CGalileoDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CGalileoView)); AddDocTemplate(pDocTemplate); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // // Pass the command line info to cmdline.ParseParam(). // Here is the expected syntax: // // iometer ? // iometer [config_file [result_file [timeout_value]]] // iometer [/c config_file] [/r results_file] [/t timeout_value] // // ? - show Iometer version number and command line syntax // // config_file - the name of the Iometer configuration file to restore // when Iometer starts (must be a valid .icf file) // // results_file - the name of a writable text file to which the test // results should be appended. If the file doesn't exist, it will be // created. // // timeout_value - the number of seconds to wait for managers to log in // when restoring a config file. // // If both config_file and results_file are specified, Iometer will // attempt to run the test in batch mode, requiring no user intervention // to load the config file, start the tests, stop the tests (if a run time // was specified in the Test Setup tab), and close Iometer. Batch mode // can be canceled by aborting the manager waiting list dialog or by // manually stopping a test while it is running. // CWinApp::ParseCommandLine(cmdline); // If the command line parser had any trouble, kill the program. if ( cmdline.m_bFail ) return FALSE; if ( !OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL) ) { OnFileNew(); } if (m_pMainWnd == NULL) { ErrorMessage("Error creating application's main frame. " "Please report this as an Iometer bug."); return FALSE; } // Fill in the local address strings. IdentifyLocalAddresses(); // Set the status bar. CRect rect; m_wndStatusBar.GetWindowRect( &rect ); int* widths; widths = (int*)malloc( sizeof(int) * 3 ); widths[0] = rect.Width() - 300; widths[1] = rect.Width() - 150; widths[2] = -1; m_wndStatusBar.GetStatusBarCtrl().SetParts( 3, widths ); free( widths ); // Set status bar text. pView->ClearStatusBar(); // Disable most buttons. pView->ButtonReset(); // make sure CGalileoApp::OnIdle() gets called at least once in a while pView->SetTimer( IDLE_TIMER, IDLE_DELAY, NULL ); // Get the full pathname for Iometer.exe. if ( !GetModuleFileName( NULL, iometer_path, sizeof( iometer_path ) ) ) { ErrorMessage( "Could not get Iometer.exe pathname!" ); // Set iometer_path to a null string; this will make NEW_WORKER_COMMAND // search for Dynamo in the current directory and $PATH iometer_path[0] = '\0'; } // Find the last backslash in the pathname, if any if ( p = strrchr( iometer_path, '\\' ) ) { // Terminate the string right after the last backslash, leaving // the full pathname of the directory containing Iometer.exe. p++; *p = '\0'; } // Build the command line to launch Dynamo. We must quote the pathname in case it // contains any spaces, but the "start" command (NEW_WORKER_COMMAND) assumes the // first quoted argument is the window title, so we must provide it twice. new_manager_command_line_format = (CString) NEW_WORKER_COMMAND + "\"" + iometer_path + NEW_WORKER_EXECUTABLE + "%s\"" + " " + "\"" + iometer_path + NEW_WORKER_EXECUTABLE + "\"%s"; if ( cmdline.GetConfigFile().IsEmpty() ) { #ifndef _DEBUG // If the default config file exists, load it. if ( ::GetFileAttributes(DEFAULT_CONFIG_FILE) != 0xFFFFFFFF ) { OpenDocumentFile(DEFAULT_CONFIG_FILE); } else { // If no config file was specified on the command line // and the default config file doesn't exist, start a // local manager.with no command line options. LaunchDynamo(); } #endif } else { // If a config file was specified on the command line, open it OpenDocumentFile( cmdline.GetConfigFile() ); } return TRUE; }
/*func*------------------------------------------------------------------------ description: in : out: -----------------------------------------------------------------------------*/ BOOL CGrEditorApp::InitInstance() { HRESULT hr; HFONT hFont; LOGFONT logFont; CGdiObject *pGdiObject; USES_CONVERSION; // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_GR_OLE_INIT_FAILED); return FALSE; } hr = ::CoInitializeSecurity (NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); assert (SUCCEEDED (hr)); // prevent the Server-Busy dialog COleMessageFilter *pFilter = AfxOleGetMessageFilter(); assert (pFilter); if (pFilter != NULL) { pFilter->EnableNotRespondingDialog(FALSE); pFilter->EnableBusyDialog(FALSE); } AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif _Module.Init (ObjectMap, m_hInstance); // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey (_T ("Softing\\4CONTROLV2\\4CONTROL Engineering")); int iValue; CString strKey, strSec; strSec.LoadString(IDS_GR_REG_SECTION); strKey.LoadString(IDS_GR_REG_RUBBLINE); iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 0); WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue ); // set Line draw mode to rubberlines strKey.LoadString(IDS_GR_REG_RUBB_RECON); iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 1); WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue ); // set Line draw mode to rubberlines strKey.LoadString(IDS_GR_REG_ZOOMVALUE); iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, 100); WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue ); // set zoom factor for 4gr // default sizes for element insertion strKey.LoadString(IDS_GR_REG_STEPSIZE); iValue = GetProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, (4<<16)+4); // <0: AutoSize:on; HiWord:X; LoWord:Y WriteProfileInt ((LPCTSTR)strSec, (LPCTSTR)strKey, iValue ); // ST actions we yes the STEditor settings .. WriteProfileInt (_T ("ST"), _T ("Case" ), 0 ); // keywords are case insensitive WriteProfileInt (_T ("ST"), _T ("Chroma" ), 1 ); // coloring enabled WriteProfileString (_T ("ST"), _T ("Background" ), _T ("255,255,255" )); // background color white WriteProfileString (_T ("ST"), _T ("Default Text" ), _T ("0,0,0" )); // text color black WriteProfileString (_T ("ST"), _T ("Quote" ), _T ("128,128,128" )); // string color grey WriteProfileString (_T ("ST"), _T ("Comment" ), _T ("0,128,0" )); // comment color red WriteProfileString (_T ("ST"), _T ("Comment Start 1"), _T ("(*" )); // comments start with (* WriteProfileString (_T ("ST"), _T ("Comment End 1" ), _T ("*)" )); // comments end with *) WriteProfileInt (_T ("ST"), _T ("Keep Tabs" ), 0 ); // tabs are not converted to spaces WriteProfileInt (_T ("ST"), _T ("Show Tabs" ), 0 ); // tabs are not visualized WriteProfileInt (_T ("ST"), _T ("Tab Size" ), 4 ); // tab is as wide as 4 spaces WriteProfileString (_T ("ST"), _T ("Keywords" ), _T ("stkeywords.ini")); // // sizeof (LOGFONT) gives you the maximum size of a LOGFONT structure. // CGdiObject::GetObject possibly returns less because the font name // at the end of the LOGFONT structure may not take the whole space // reserved for it. hFont = (HFONT)GetStockObject (ANSI_FIXED_FONT); pGdiObject = CGdiObject::FromHandle (hFont); if (pGdiObject != NULL && pGdiObject->GetObject (sizeof (LOGFONT), &logFont) != 0) { int iFontSize; CWindowDC dc (m_pMainWnd); WriteProfileString (_T ("ST"), _T ("Font Name"), A2T (logFont.lfFaceName)); iFontSize = MulDiv (logFont.lfHeight, 72, dc.GetDeviceCaps (LOGPIXELSY)); WriteProfileInt (_T ("ST"), _T ("Font Size"), iFontSize); WriteProfileInt (_T ("ST"), _T ("Font Weight"), logFont.lfWeight); WriteProfileInt (_T ("ST"), _T ("Font Italic"), logFont.lfItalic); WriteProfileInt (_T ("ST"), _T ("CharSet"), logFont.lfCharSet); }; LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. m_pDocTemplate = new CMultiDocTemplate( IDR_GR_TYPE, RUNTIME_CLASS(CGrEditorDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CGrEditorView)); m_pDocTemplate->SetServerInfo( IDR_GR_TYPE_SRVR_EMB, IDR_GR_TYPE_SRVR_IP, RUNTIME_CLASS(CInPlaceFrame)); AddDocTemplate(m_pDocTemplate); // Connect the COleTemplateServer to the document template. // The COleTemplateServer creates new documents on behalf // of requesting OLE containers by using information // specified in the document template. m_server.ConnectTemplate(clsid, m_pDocTemplate, FALSE); // Register all OLE server factories as running. This enables the // OLE libraries to create objects from other applications. COleTemplateServer::RegisterAll(); // Note: MDI applications register all server objects without regard // to the /Embedding or /Automation on the command line. // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_GR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // create a dummy image .. to solve the problem with DeleteTempMap in OnIdle m_pDummyImage = new CImageList(); VERIFY (m_pDummyImage->Create (16, 15, TRUE, 0, 1)); CBitmap bm; bm.LoadBitmap (IDR_GR_MAINFRAME); m_pDummyImage->Add (&bm, RGB (192, 192, 192)); // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // Parse command line for standard shell commands, DDE, file open CSTCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Check to see if launched as OLE server if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { // Application was run with /Embedding or /Automation. Don't show the // main window in this case. return TRUE; } // When a server application is launched stand-alone, it is a good idea // to update the system registry in case it has been damaged. m_server.UpdateRegistry(OAT_DOC_OBJECT_SERVER); COleObjectFactory::UpdateRegistryAll(); if (cmdInfo.m_bRegServer) { TCHAR szModule[_MAX_PATH+10]; LPOLESTR pszModule; HRESULT hr; LPTYPELIB pTypeLib; USES_CONVERSION; ::GetModuleFileName (m_hInstance, szModule, _MAX_PATH); pszModule = T2OLE (szModule); hr = LoadTypeLib (pszModule, &pTypeLib); if (SUCCEEDED (hr)) { hr = RegisterTypeLib (pTypeLib, pszModule, NULL); pTypeLib->Release (); }; return (FALSE); }; // Prevents ProcessShellCommand from displaying // a message box when unregistering. if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { cmdInfo.m_bRunEmbedded = true; }; // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
static HB_BOOL hb_SetDefaultPrinter( LPCTSTR lpPrinterName ) { #if ! defined( HB_OS_WIN_CE ) BOOL bFlag; DWORD dwNeeded = 0; HANDLE hPrinter = NULL; PRINTER_INFO_2 * ppi2 = NULL; LPTSTR pBuffer = NULL; /* If Windows 95 or 98, use SetPrinter. */ if( hb_iswin9x() ) { /* Open this printer so you can get information about it. */ bFlag = OpenPrinter( ( LPTSTR ) lpPrinterName, &hPrinter, NULL ); if( ! bFlag || ! hPrinter ) return HB_FALSE; /* The first GetPrinter() tells you how big our buffer must be to hold ALL of PRINTER_INFO_2. Note that this will typically return FALSE. This only means that the buffer (the 3rd parameter) was not filled in. You do not want it filled in here. */ SetLastError( 0 ); bFlag = GetPrinter( hPrinter, 2, 0, 0, &dwNeeded ); if( ! bFlag ) { if( ( GetLastError() != ERROR_INSUFFICIENT_BUFFER ) || ( dwNeeded == 0 ) ) { ClosePrinter( hPrinter ); return HB_FALSE; } } /* Allocate enough space for PRINTER_INFO_2. */ ppi2 = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded ); /* The second GetPrinter() will fill in all the current information so that all you have to do is modify what you are interested in. */ bFlag = GetPrinter( hPrinter, 2, ( LPBYTE ) ppi2, dwNeeded, &dwNeeded ); if( ! bFlag ) { ClosePrinter( hPrinter ); hb_xfree( ppi2 ); return HB_FALSE; } /* Set default printer attribute for this printer. */ ppi2->Attributes |= PRINTER_ATTRIBUTE_DEFAULT; bFlag = SetPrinter( hPrinter, 2, ( LPBYTE ) ppi2, 0 ); if( ! bFlag ) { ClosePrinter( hPrinter ); hb_xfree( ppi2 ); return HB_FALSE; } /* Tell all open programs that this change occurred. Allow each program 1 second to handle this message. */ SendMessageTimeout( HWND_BROADCAST, WM_SETTINGCHANGE, 0L, ( LPARAM ) ( LPCTSTR ) TEXT( "windows" ), SMTO_NORMAL, 1000, NULL ); } /* If Windows NT, use the SetDefaultPrinter API for Windows 2000, or WriteProfileString for version 4.0 and earlier. */ else if( hb_iswinnt() ) { if( hb_iswin2k() ) /* Windows 2000 or later (use explicit call) */ { HMODULE hWinSpool; typedef BOOL ( WINAPI * DEFPRINTER )( LPCTSTR ); /* stops warnings */ DEFPRINTER fnSetDefaultPrinter; hWinSpool = hbwapi_LoadLibrarySystem( TEXT( "winspool.drv" ) ); if( ! hWinSpool ) return HB_FALSE; fnSetDefaultPrinter = ( DEFPRINTER ) HB_WINAPI_GETPROCADDRESST( hWinSpool, "SetDefaultPrinter" ); if( ! fnSetDefaultPrinter ) { FreeLibrary( hWinSpool ); return HB_FALSE; } bFlag = ( *fnSetDefaultPrinter )( lpPrinterName ); FreeLibrary( hWinSpool ); if( ! bFlag ) return HB_FALSE; } else /* NT4.0 or earlier */ { HB_ISIZ nStrLen; /* Open this printer so you can get information about it. */ bFlag = OpenPrinter( ( LPTSTR ) lpPrinterName, &hPrinter, NULL ); if( ! bFlag || ! hPrinter ) return HB_FALSE; /* The first GetPrinter() tells you how big our buffer must be to hold ALL of PRINTER_INFO_2. Note that this will typically return FALSE. This only means that the buffer (the 3rd parameter) was not filled in. You do not want it filled in here. */ SetLastError( 0 ); bFlag = GetPrinter( hPrinter, 2, 0, 0, &dwNeeded ); if( ! bFlag ) { if( ( GetLastError() != ERROR_INSUFFICIENT_BUFFER ) || ( dwNeeded == 0 ) ) { ClosePrinter( hPrinter ); return HB_FALSE; } } /* Allocate enough space for PRINTER_INFO_2. */ ppi2 = ( PRINTER_INFO_2 * ) hb_xgrab( dwNeeded ); /* The second GetPrinter() fills in all the current information. */ bFlag = GetPrinter( hPrinter, 2, ( LPBYTE ) ppi2, dwNeeded, &dwNeeded ); if( ( ! bFlag ) || ( ! ppi2->pDriverName ) || ( ! ppi2->pPortName ) ) { ClosePrinter( hPrinter ); hb_xfree( ppi2 ); return HB_FALSE; } nStrLen = hbwapi_tstrlen( lpPrinterName ) + hbwapi_tstrlen( ppi2->pDriverName ) + hbwapi_tstrlen( ppi2->pPortName ) + 2; /* Allocate buffer big enough for concatenated string. String will be in form "printername,drivername,portname". */ pBuffer = ( LPTSTR ) hb_xgrab( ( nStrLen + 1 ) * sizeof( TCHAR ) ); pBuffer[ 0 ] = TEXT( '\0' ); /* Build string in form "printername,drivername,portname". */ hbwapi_tstrncat( pBuffer, lpPrinterName, nStrLen ); hbwapi_tstrncat( pBuffer, TEXT( "," ), nStrLen ); hbwapi_tstrncat( pBuffer, ppi2->pDriverName, nStrLen ); hbwapi_tstrncat( pBuffer, TEXT( "," ), nStrLen ); hbwapi_tstrncat( pBuffer, ppi2->pPortName, nStrLen ); /* Set the default printer in win.ini and registry. */ bFlag = WriteProfileString( TEXT( "windows" ), TEXT( "device" ), pBuffer ); if( ! bFlag ) { ClosePrinter( hPrinter ); hb_xfree( ppi2 ); hb_xfree( pBuffer ); return HB_FALSE; } } /* Tell all open programs that this change occurred. Allow each app 1 second to handle this message. */ SendMessageTimeout( HWND_BROADCAST, WM_SETTINGCHANGE, 0L, 0L, SMTO_NORMAL, 1000, NULL ); } /* Clean up. */ if( hPrinter ) ClosePrinter( hPrinter ); if( ppi2 ) hb_xfree( ppi2 ); if( pBuffer ) hb_xfree( pBuffer ); return HB_TRUE; #else HB_SYMBOL_UNUSED( lpPrinterName ); return HB_FALSE; #endif }
/************************************************************ SaveWallpaper Saves the current picture into the specified file. Installs it as the system wallpaper (uses name given). Sets the INI tiled flag to the passed value returns FALSE if it could not save wallpaper. ************************************************************/ BOOL SaveWallpaper( LPSTR lpName, BOOL fTiled ) { WORD idDataType; STRING szSaveAs; LPFRAME lpFrame; int nBits, nPlanes, nDepth, nOutWidth, nOutHeight; if ( !lpImage ) return(FALSE); if ( !(lpFrame = ImgGetBaseEditFrame(lpImage)) ) return(FALSE); AstralCursor( IDC_WAIT ); /* Put up the wait cursor */ nBits = GetDeviceCaps( Window.hDC, BITSPIXEL ); nPlanes = GetDeviceCaps( Window.hDC, PLANES ); nDepth = nBits * nPlanes; nOutWidth = GetDeviceCaps( Window.hDC,HORZRES); nOutHeight = GetDeviceCaps( Window.hDC,VERTRES); // decide on proper depth if ( FrameType(lpFrame) == FDT_LINEART ) idDataType = IDC_SAVELA; else if (nDepth <= 4) { if( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVESP; else idDataType = IDC_SAVE4BITCOLOR; } else if( nDepth <= 8 || !Control.Save24BitWallpaper) { if ( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVECT; else idDataType = IDC_SAVE8BITCOLOR; } else { if ( FrameType(lpFrame) == FDT_GRAYSCALE ) idDataType = IDC_SAVECT; else idDataType = IDC_SAVE24BITCOLOR; } // Save file into the Windows directory GetWindowsDirectory(szSaveAs, sizeof(FNAME)); FixPath( szSaveAs ); lstrcat( szSaveAs, filename(lpName) ); stripext( szSaveAs ); lstrcat( szSaveAs, ".BMP" ); if ( !AstralImageSave( IDN_BMP, idDataType, szSaveAs ) ) goto ErrorExit; // Make szSaveAs the current wallpaper and apply WriteProfileString( "Desktop", "TileWallPaper", (fTiled?"1":"0") ); SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename(szSaveAs), SPIF_UPDATEINIFILE ); AstralCursor( NULL ); /* Revert back to the old cursor */ return (TRUE); ErrorExit: AstralCursor( NULL ); /* Revert back to the old cursor */ return(FALSE); }
/* =========== */ int EXPORT FAR PASCAL FontDlgProc (HWND hDlg, UINT wMsg, UINT wParam, LONG lParam) { switch (wMsg) { case WM_INITDIALOG: hNewFont = NULL; { /*-setup the dialog box's caption */ char s[40]; strcpy (s, ProgName); strcat (s, " - Font selection"); SetWindowText (hDlg, s); } /*-set the Bold button */ GetFontMetrics (hEmacsFont, &Metrics, FaceName); CheckDlgButton (hDlg, ID_BOLD, (Metrics.tmWeight > 550)); { /*-simulate a mouse click on the appropriate charset radiobutton. This will initialize all the other controls */ WORD id; id = (Metrics.tmCharSet == ANSI_CHARSET ? ID_ANSI : ID_OEM); SendMessage (hDlg, WM_COMMAND, #if WINDOW_MSWIN32 MAKELONG(id, BN_CLICKED), (long)GetDlgItem (hDlg, id)); #else id, MAKELONG(GetDlgItem (hDlg, id), BN_CLICKED)); #endif } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case 1: /* OK button */ if (NOTIFICATION_CODE == BN_CLICKED) { AcceptFont: if (hEmacsFont) DeleteObject (hEmacsFont); hEmacsFont = hNewFont; EndDialog (hDlg, TRUE); /* no need to unhook the SAMPLE's font, it is not destroyed since it will be used by emacs */ } else return FALSE; break; case 2: /* Cancel button */ if (NOTIFICATION_CODE == BN_CLICKED) goto CancelFont; else return FALSE; case ID_SAVEFONT: if (NOTIFICATION_CODE == BN_CLICKED) { /*-save the facename, bold status and size into WIN.INI, then perform as the OK button */ char NumText[17]; GetFontMetrics (hNewFont, &Metrics, FaceName); WriteProfileString (ProgName, "FontName", FaceName); WriteProfileString (ProgName, "CharSet", itoa (Metrics.tmCharSet, NumText, 10)); WriteProfileString (ProgName, "FontHeight", itoa (Metrics.tmHeight, NumText, 10)); WriteProfileString (ProgName, "FontWidth", itoa (Metrics.tmAveCharWidth, NumText, 10)); WriteProfileString (ProgName, "FontWeight", itoa (Metrics.tmWeight, NumText, 10)); } else return FALSE; goto AcceptFont; case ID_ANSI: case ID_OEM: if (NOTIFICATION_CODE == BN_CLICKED) { CheckRadioButton (hDlg, ID_1ST_CHARSET, ID_LAST_CHARSET, LOWORD(wParam)); BuildFaceList (hDlg, FaceName); } else return FALSE; break; case ID_BOLD: if (NOTIFICATION_CODE == BN_CLICKED) NewFont (hDlg, TRUE); else return FALSE; break; case ID_FONT: switch (NOTIFICATION_CODE) { case LBN_SELCHANGE: BuildSizeList (hDlg, &Metrics); break; case LBN_DBLCLK: /* treated as OK */ goto AcceptFont; default: return FALSE; } break; case ID_FONTSIZE: switch (NOTIFICATION_CODE) { case CBN_SELCHANGE: NewFont (hDlg, FALSE); break; case CBN_EDITCHANGE: { BOOL FontSizeOK; GetDlgItemInt (hDlg, ID_FONTSIZE, &FontSizeOK, FALSE); if (FontSizeOK) NewFont (hDlg, TRUE); else MessageBeep (0); } break; case CBN_DBLCLK: /* treated as OK */ goto AcceptFont; default: return FALSE; } break; default: return FALSE; } break; case WM_SYSCOMMAND: if ((wParam & 0xFFF0) == SC_CLOSE) { CancelFont: EndDialog (hDlg, FALSE); if (hNewFont) { SendDlgItemMessage (hDlg, ID_SAMPLE, WM_SETFONT, 0, FALSE); /* reset to SYSTEM_FONT before deleting the font */ DeleteObject (hNewFont); } return TRUE; } return FALSE; default: return FALSE; } return FALSE; } /* FontDlgProc */
/* main - top-level driver * */ int main (int c, char *v[]) { char szname[MAX_PATH]; BOOL fFilesOnly = FALSE; LoadIni (); SHIFT (c, v); if (c == 0) { printf ("Symref: Server = %s\n", szServer); printf (" Scope = '%s'\n", szScope); } else while (c) { if (!strcmp (*v, "-d") && c >= 2) { SHIFT (c, v); SRSendNewDatabase (*v); } else if (!strcmp (*v, "-f")) fFilesOnly = TRUE; else if (!strcmp (*v, "-i")) { SHIFT (c, v); while (c != 0 && (*v[0] != '-' || !strcmp (*v, "-"))) { if (!strcmp (*v, "-")) { while (fgetl (szname, MAX_PATH, stdin)) if (strlen (szname) != 0) SRSendAddDirectory (szname); } else SRSendAddDirectory (*v); SHIFT (c, v); } continue; } else if (!strcmp (*v, "-ig")) { SHIFT (c, v); while (c != 0 && (*v[0] != '-' || !strcmp (*v, "-"))) { if (!strcmp (*v, "-")) { while (fgetl (szname, MAX_PATH, stdin)) if (strlen (szname) != 0) SRSendNoiseWord (szname); } else SRSendNoiseWord (*v); SHIFT (c, v); } continue; } else if (!strcmp (*v, "-ie")) { SHIFT (c, v); while (c != 0 && (*v[0] != '-' || !strcmp (*v, "-"))) { if (!strcmp (*v, "-")) { while (fgetl (szname, MAX_PATH, stdin)) if (strlen (szname) != 0) SRSendAddExtention (szname); } else SRSendAddExtention (*v); SHIFT (c, v); } continue; } else if (!strcmp (*v, "-s") && c >= 2) { SHIFT (c, v); WriteProfileString (PSZAPPNAME, PSZSCOPE, *v); LoadIni (); } else if (!strcmp (*v, "-S") && c >= 2) { SHIFT (c, v); WriteProfileString (PSZAPPNAME, PSZSERVER, *v); LoadIni (); } else if (!strcmp (*v, "-shutdown")) SRSendShutdown (); else if (!strcmp (*v, "-sync")) SRSendSync (); else if (*v[0] == '-') Usage (); else SRSendSymLocate (*v, fFilesOnly, szScope); SHIFT (c, v); } return 0; }
BOOL CPrinterInfo::RemoveEntry(LPCSTR pEntry) { return WriteProfileString(pEntry, NULL); }
DoFileSaveAs(void) { /* This routine handles input to the Save dialog box. */ static CHAR szDefault[ cchMaxFile ]; extern int vfTextOnlySave; extern DoSaveAsFilenameGet(LPSTR,LPSTR,int *,int *,int * ,int *); BOOL bDontDelPictures=FALSE; int fWordFmt, fTextOnly, fBackup, fOldWrite; CHAR szFullNameNewDoc[ cchMaxFile ]; // full name of selection CHAR szShortNameNewDoc[ cchMaxFile ]; // file name of selection CHAR szDocName[ cchMaxFile ]; // file name of current #define szFullNameCurDoc (**((**hpdocdod)[docCur].hszFile)) // full name of current #define pDod ((struct DOD *)&(**hpdocdod)[docCur]) { int cch = 0; CHAR szDOSPath[ cchMaxFile ]; if (FNormSzFile( szDOSPath, "", dtyNormal )) { if ((cch=CchSz( szDOSPath )-2) > 2) { Assert( szDOSPath[ cch ] == '\\'); szDOSPath [cch] = '\0'; } #if 0 if (cch > 3) szDOSPath [cch] = '\\'; #endif } else szDOSPath[0] = '\0'; if (szFullNameCurDoc [0] != '\0') { /* Set default string for filename edit area */ CHAR szDocPath[ cchMaxFile ]; // path to current FreezeHp(); SplitSzFilename( szFullNameCurDoc, szDocPath, szDocName ); /* Default filename does not include the document's path if it is == the current directory path */ if (WCompSz( szDOSPath, szDocPath ) == 0) bltsz(szDocName, szDefault); else bltsz(szFullNameCurDoc, szDefault); MeltHp(); } else { szDefault[0] = szDocName[0] = '\0'; } } fTextOnly = vfTextOnlySave; fBackup = vfBackupSave; fWordFmt = vWordFmtMode & ~CONVFROMWORD; fOldWrite = vfOldWriteFmt; EnableOtherModeless(FALSE); while(1) { if (!DoSaveAsFilenameGet(szDefault,szFullNameNewDoc,&fBackup,&fTextOnly,&fWordFmt,&fOldWrite)) goto end; else { int dty; if (szFullNameNewDoc[0] == '\0') goto end; if (fOldWrite || fWordFmt || fTextOnly) { if (!WannaDeletePictures(docCur,fOldWrite ? SF_OLDWRITE : SF_WORD)) continue; } StartLongOp(); szFileExtract(szFullNameNewDoc, szShortNameNewDoc); #ifdef INTL /* International version */ /* Read the "Microsoft Word Format" button */ /* vWordFmtMode is used in WriteFn. If true, will convert to Word format, if false, no conversion is done. Another value, CONVFROMWORD, can be given during an open to allow saving a Word document in Write format. */ if (fWordFmt) /* if set, make the default extension be doc instead of wri for word docs */ dty = dtyWordDoc; else #endif /* International version */ dty = dtyNormal; #if WINVER >= 0x300 /* Currently: FNormSzFile *TAKES* an OEM sz, and *RETURNS* an ANSI sz ..pault */ #endif if ( pDod->fReadOnly && WCompSz( szFullNameNewDoc, szFullNameCurDoc ) == 0) { /* Must save read-only file under a different name */ Error( IDPMTReadOnly ); goto NSerious; /* Error not serious, stay in dialog */ } #if WINVER >= 0x300 else if (WCompSz(szFullNameCurDoc, szFullNameNewDoc) == 0 && vWordFmtMode == CONVFROMWORD && vfTextOnlySave == fTextOnly) /* User has loaded a text file and is going to save under the same name without changing formats, *OR* has loaded a Word document and is going to save in the same format -- don't prompt "replace file?" ..pault 1/17/90 */ ; #endif else if ((WCompSz(szFullNameCurDoc, szFullNameNewDoc) != 0 #ifdef INTL /* International version */ /* vWordFmtMode hasn't be reset yet */ || ( vWordFmtMode == CONVFROMWORD) #endif /* International version */ ) && FExistsSzFile( dtyNormal, szFullNameNewDoc ) ) { /* User changed the default string and specified a filename for which the file already exists. Or, we did a Word format conversion, forcing the .WRI extension on the file, and a file with that name exists.(International version only).o Note that vfWordFmtMode will be set to True or False below, so this check is made only on the first save after a Word conversion. Prompt to make sure it's ok to trash the existing one */ CHAR szFileUp[ cchMaxFile ]; CHAR szUserOEM[cchMaxFile]; /* ..converted to OEM */ CHAR szT[ cchMaxSz ]; CchCopyUpperSz( szShortNameNewDoc, szFileUp ); MergeStrings (IDSTRReplaceFile, szFileUp, szT); #if WINVER >= 0x300 /* access() expects OEM! */ AnsiToOem((LPSTR) szFullNameNewDoc, (LPSTR) szUserOEM); /* Make sure we don't let someone try to save to a file to which we do not have r/w permission */ Diag(CommSzNum("fnSaveAs: access(write_perm)==", access(szUserOEM, WRITE_PERMISSION))); Diag(CommSzNum(" szExists()==", FExistsSzFile( dtyNormal, szFullNameNewDoc ))); if (access(szUserOEM, WRITE_PERMISSION) == -1) { /* THIS COULD BE A CASE OF WRITING TO A FILE WITH R/O ATTRIBUTE, *OR* A SHARING ERROR! IMPROVE ERROR MESSAGE HERE ..pault 11/2/89 */ //Error( IDPMTSDE2 ); Error( IDPMTReadOnly ); goto NSerious; /* Error not serious, stay in dialog */ } #endif } vfTextOnlySave = fTextOnly; vfBackupSave = fBackup; vfOldWriteFmt = fOldWrite; #ifdef INTL /* International version */ /* vWordFmtMode is used in WriteFn. If true, will convert to Word format, if false, no conversion is done. Another value, CONVFROMWORD, can be given during an open to allow saving a Word document in Write format. */ vWordFmtMode = fWordFmt; #endif /* International version */ /* Record whether a backup was made or not. */ WriteProfileString( (LPSTR)szWriteProduct, (LPSTR)szBackup, vfBackupSave ? (LPSTR)"1" : (LPSTR)"0" ); /* Save the document */ CmdXfSave( szFullNameNewDoc,!vfTextOnlySave, vfBackupSave, vhcArrow); if (vfDiskFull || vfSysFull) goto NSerious; /* Case 1: Serious error. Leave the dialog. */ if (vfDiskError) { EndLongOp( vhcArrow ); goto end; } /* Case 2: Saved OK: set the new title, leave the dialog. */ else if (!WCompSz( szFullNameNewDoc, szFullNameCurDoc )) { #if defined(OLE) ObjRenamedDoc(szFullNameNewDoc); ObjSavedDoc(); #endif SetTitle(szShortNameNewDoc); #if WINVER >= 0x300 FreeUnreferencedFns(); #endif /* Update the fReadOnly attribute (9.10.91) v-dougk */ pDod->fReadOnly = FALSE; // can't be readonly if just saved EndLongOp( vhcArrow ); goto end; } /* Case 3: Nonserious error (disk full, bad path, etc.). stay in dialog. */ else { NSerious: ferror = FALSE; EndLongOp( vhcArrow ); StayInDialog: CloseEveryRfn( TRUE ); } } } // end of while(1) end: EnableOtherModeless(FALSE); } /* end of DoFileSaveAs */
void CGMapViewerApp::SaveConfig() { CString csValue; WriteProfileString("Settings", "Ch1 Basefile Path", m_gvInfo.csBasePath[0]); WriteProfileString("Settings", "Ch2 Basefile Path", m_gvInfo.csBasePath[1]); WriteProfileString("Settings", "Ch3 Basefile Path", m_gvInfo.csBasePath[2]); WriteProfileString("Settings", "Ch4 Basefile Path", m_gvInfo.csBasePath[3]); WriteProfileInt("Settings", "Track Mode", m_gvInfo.nTrackMode); WriteProfileInt("Settings", "Cursor1 Visable", m_gvInfo.bCursor1Visible?1:0); WriteProfileInt("Settings", "Cursor2 Visable", m_gvInfo.bCursor2Visible?1:0); WriteProfileInt("Settings", "Measure Graph Visable", m_gvInfo.bMeasureGraphVisible?1:0); WriteProfileInt("Settings", "Filtered Graph Visable", m_gvInfo.bFilterGraphVisible?1:0); WriteProfileInt("Settings", "Base Graph Visable", m_gvInfo.bBaseGraphVisible?1:0); WriteProfileInt("Settings", "Filtered Base Graph Visable", m_gvInfo.bBaseFilterGraphVisible?1:0); WriteProfileInt("Settings", "Difference Graph Visable", m_gvInfo.bDiffGraphVisible?1:0); WriteProfileInt("Settings", "Zoom Hold", m_gvInfo.bHoldZoom?1:0); WriteProfileInt("Settings", "Find Peak", m_gvInfo.bFindPeak?1:0); int nEventMode=0; switch(m_gvInfo.uEventMode) { case EVENT_OPEN: nEventMode = 0; break; case EVENT_SHORT: nEventMode = 1; break; default: nEventMode = 4; } WriteProfileInt("Settings", "Event Mode", nEventMode); csValue.Format("%f", m_gvInfo.dMinX); WriteProfileString("Settings", "Zoom MinX", csValue); csValue.Format("%f", m_gvInfo.dMaxX); WriteProfileString("Settings", "Zoom MaxX", csValue); csValue.Format("%f", m_gvInfo.dMinY); WriteProfileString("Settings", "Zoom MinY", csValue); csValue.Format("%f", m_gvInfo.dMaxY); WriteProfileString("Settings", "Zoom MaxY", csValue); WriteProfileInt("Settings", "Use Basedata", m_gvInfo.bUseBase?1:0); WriteProfileInt("Settings", "ScanPos 5", m_gvInfo.nScanPos5); WriteProfileInt("Settings", "ScanPos 15", m_gvInfo.nScanPos15); WriteProfileInt("Settings", "ScanPos 45", m_gvInfo.nScanPos45); WriteProfileInt("Settings", "ScanPos 100", m_gvInfo.nScanPos100); WriteProfileInt("Settings", "ScanPos 200", m_gvInfo.nScanPos200); WriteProfileInt("Settings", "ScanPos 500", m_gvInfo.nScanPos500); WriteProfileInt("Settings", "ScanPos 1000", m_gvInfo.nScanPos1000); WriteProfileInt("Settings", "ScanPos 2000", m_gvInfo.nScanPos2000); WriteProfileInt("Settings", "ScanPos 5000", m_gvInfo.nScanPos5000); WriteProfileInt("Settings", "ScanPos 10000", m_gvInfo.nScanPos10000); WriteProfileString("Settings", "Last Access Directory", m_gvInfo.csLastAccessDir); /*------------------------------------------------------------------------- * Smoothing 적용횟수 *-----------------------------------------------------------------------*/ WriteProfileInt("Settings", "Smoothing Repeat Count", m_gvInfo.nRepeatCnt); /*------------------------------------------------------------------------- * 에러보정 *-----------------------------------------------------------------------*/ WriteProfileInt("Settings", "Smoothing Error Correct", m_gvInfo.nSmoothErrCor); }
BOOL WINPROC EXPORT DlgRegisterProc(HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam) /****************************************************************************/ { BOOL bHandled = TRUE; FNAME szCode; FNAME szKey; FNAME szTemp; BYTE bChecksum = 0; bool bGoodCode; int len; LICENSEINFO AppLicenseInfo; switch (wMsg) { case WM_COMMAND: #ifdef WIN32 switch (LOWORD(wParam)) #else switch (wParam) #endif { case IDOK: szCode[0] = 0; GetDlgItemText(hWnd, IDC_REG_KEY, szKey, sizeof(szKey)); GetDlgItemText(hWnd, IDC_REG_CODE, szCode, sizeof(szCode)); MGXGenerateLicenseKey(szCode, 0, 0, 0, szTemp); bGoodCode = (lstrcmpi(szTemp, szKey) == 0); if (!bGoodCode) { LoadString (hInstAstral,IDS_REG_CODE_MSG,szKey,sizeof(szKey)); LoadString (hInstAstral,IDS_REG_CODE_TITLE,szCode,sizeof(szCode)); MessageBox(hWnd, szKey, szCode, MB_OK | MB_ICONEXCLAMATION); } else { WriteProfileString(lpCodeSection[iType], lpCodeEntry[iType], szCode); WriteProfileString(lpKeySection[iType], lpKeyEntry[iType], szKey); AstralDlgEnd(hWnd, YES); } break; case IDCANCEL: AstralDlgEnd(hWnd, NO); break; default: bHandled = FALSE; } // switch (wParam) break; case WM_CTLCOLOR: return ( (BOOL)SetControlColors ( (HDC)wParam, hWnd, (HWND)LOWORD(lParam), HIWORD(lParam) )); case WM_INITDIALOG: SET_CLASS_HBRBACKGROUND(hWnd, ( HBRUSH )GetStockObject(LTGRAY_BRUSH)); CenterPopup (hWnd); len = GetProfileString(lpCodeSection[iType], lpCodeEntry[iType], "", szCode, sizeof(szCode)); if (!len) { CreateNewLicense(&AppLicenseInfo); LicenseToString(&AppLicenseInfo, szCode); WriteProfileString(lpCodeSection[iType], lpCodeEntry[iType], szCode); } SetDlgItemText(hWnd, IDC_REG_CODE, szCode); break; case WM_DESTROY: break; default: bHandled = FALSE; } // switch (wMsg) return bHandled; }
BOOL CmfcClient1App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 创建 shell 管理器,以防对话框包含 // 任何 shell 树视图控件或 shell 列表视图控件。 CShellManager *pShellManager = new CShellManager; // 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题 CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("webaryMfcClient1")); WriteProfileString("UserInfo", "version", "1.1"); CmfcClient1Dlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } else if (nResponse == -1) { TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n"); TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n"); } // 删除上面创建的 shell 管理器。 if (pShellManager != NULL) { delete pShellManager; } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
BOOLEAN MissypSetLegalNotice( HWND hwnd, PUNICODE_STRING Caption, PUNICODE_STRING Body ) /*++ Routine Description: This function is used to get the current legal notice caption and text. If the strings are both zero in length, then they will be applied. The result will be that no legal notice will be displayed. Arguments hwnd - The caller's window. This is used if we need to put up an error popup. Caption - Points to a unicode string which is to be applied. Body - Points to a unicode string which is to be applied. Return Values: TRUE - The value has been successfully retrieved. FALSE - we ran into trouble querying the current setting. If an error is encountered, then an error popup will be displayed by this routine. --*/ { BOOLEAN Result; Result = WriteProfileString( TEXT("Winlogon"), TEXT("LegalNoticeCaption"), Caption->Buffer); if (Result) { Result = WriteProfileString( TEXT("Winlogon"), TEXT("LegalNoticeText"), Body->Buffer); } if (Result) { // // Set the enabled/disabled value in our item control block // if ( (Caption->Length != 0) || (Body->Length != 0) ) { MissypLegalNoticeItem->Value.Bool = TRUE; } else { MissypLegalNoticeItem->Value.Bool = FALSE; } MissypMarkLegalNoticeValueCurrent(); } else { // // Put up a pop-up indicating that a problem occured // MissypPopUp( hwnd, MISSYP_POP_UP_CANT_SET_LEGAL_NOTICE, MISSYP_STRING_TITLE_ERROR); } return( Result ); }
BOOL CWedApp::SaveAllModified() { // Save reopen information: CString buf; CPtrList il; int row, col; // Save list of buffers if(!comline) { int count = 0; POSITION Pos = pDocTemplate->GetFirstDocPosition(); // Make a list, current edited buffer as last for(;;) { if(!Pos) break; CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos); POSITION pos = doc->GetFirstViewPosition(); CView *cv = doc->GetNextView(pos); ASSERT_VALID(cv); if(cv != currentedit) il.AddTail(cv); } if(currentedit) il.AddTail(currentedit); POSITION pos = il.GetHeadPosition(); for(;;) { if(!pos) break; CView *cv = (CView*)il.GetNext(pos); if(!cv) break; ASSERT_VALID(cv); CWedDoc* doc = (CWedDoc*)cv->GetDocument(); if(!doc) break; ASSERT_VALID(doc); CString fline =doc->strlist.GetLine(0); // If it is a new doc if(doc->strlist.GetCount() == 1 && fline.GetLength() == 0) { //P2N("New doc: %d\r\n", doc); } else { CString file = doc->GetPathName(); row = ((CWedView*)cv)->row; col = ((CWedView*)cv)->col; buf.Format("%d", count + 1); WriteProfileString(strSection, strStringItem + buf, file); WriteProfileInt(strSection, strStringItem + buf + "row", row); WriteProfileInt(strSection, strStringItem + buf + "col", col); count++; } } WriteProfileInt(strSection, strIntItem, count); } // Serialize holdings message ("Saving holdings"); SaveHoldings(); // Serialize macros message ("Saving macros"); SaveMacros(); // Save config information: CTime t = CTime::GetCurrentTime(); WriteProfileInt(strConfig, "strLastUsage", (int)t.GetTime()); WriteProfileInt(strConfig, "strUsage", use); // Save main frame window placement WINDOWPLACEMENT wp; pMainFrame->GetWindowPlacement(&wp); WriteProfileInt(strConfig, "WindowState", wp.showCmd); // Save file informaion // Save current window focus: // Save font info LOGFONT lf; ff.GetObject(sizeof(LOGFONT), &lf); WriteProfileString(strConfig, strFontName, lf.lfFaceName); WriteProfileInt(strConfig, strFontSize, lf.lfHeight); WriteProfileInt(strConfig, strFontWeight, lf.lfWeight); WriteProfileInt(strConfig, strFontItalic, lf.lfItalic); // Save color info WriteProfileInt(strConfig, strColorBg, bgcol); WriteProfileInt(strConfig, strColorFg, fgcol); WriteProfileInt(strConfig, strColorSel , selcol ); WriteProfileInt(strConfig, strColorCSel, cselcol); WriteProfileInt(strConfig, strColorAdd , cadd ); WriteProfileInt(strConfig, strColorDel , cdel ); WriteProfileInt(strConfig, strColorChg , cchg ); WriteProfileInt(strConfig, strColorComm, comm ); WriteProfileInt(strConfig, strColorSrc , srcc ); WriteProfileInt(strConfig, strColorLong , clng ); // Save backwrap WriteProfileInt(strConfig, strBackWrap , backwrap); // Save tab2space WriteProfileInt(strConfig, strTab2Space, Tab2Space); // Save tabstop WriteProfileInt(strConfig, strTabStop, tabstop); return CWinApp::SaveAllModified(); }