perhaps next code snippet helps you CStringArray m_pszFileNames void ::TestFile() { struct _finddata_t g_file; long hFile, lTime; CString strName, strPath, strCurrentPath; m_pszFileNames.RemoveAll(); strPath = "c:\testpath"; /* Get the current working directory: */ char buffer[_MAX_PATH]; _getcwd( buffer, _MAX_PATH ); strCurrentPath.Format( _T("%s"), buffer); _tchdir(strPath); if( (hFile = _findfirst( "*.*", &g_file )) == -1L ) { printf( "No files in current directory!\n" ); } else { strName = g_file.name; m_pszFileNames.Add(strName); /* Find the rest of the *.* files */ while( _findnext( hFile, &g_file ) == 0 ) { strName = g_file.name; m_pszFileNames.Add(strName); lTime = g_file.time_write; } _findclose( hFile ); } _tchdir(strCurrentPath); }
dan o
Posts
-
How to use GetTimeZoneInformation -
How to use GetTimeZoneInformationBOOL bFound = FALSE; for(i=0;i<=m_pszTimeZones.GetUpperBound();i++) { strTest = m_pszTimeZones.GetAt(i); strTemp = m_pszTimeZones.GetAt(i); stdTT = m_pszNames.GetAt(i); strTest = strTest.Mid(4,6); if ( strTest == strIn) { // Here find the correct zone name SetDetails(strTemp); SetDlgItemText(IDC_STD, stdTT); bFound = TRUE; break; } } if (!bFound) { AfxMessageBox("Error, No Found"); }
-
How to use GetTimeZoneInformationi wonder if you did exactly as below .h m_pszTimeZones m_pszTimeZonesNames .cpp void ::TestTZ() { HKEY hKey, Key; DWORD dwType = REG_SZ; int iRet = 0; CString strName, strValue, strPath, strKey; strPath = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"); iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strPath, 0, KEY_READ, &hKey); if (iRet != ERROR_SUCCESS) return; TCHAR achKey[MAX_PATH]; TCHAR achClass[MAX_PATH] = _T(""); DWORD cchClassName = MAX_PATH; DWORD cSubKeys; DWORD cbMaxSubKey; DWORD cchMaxClass; DWORD cValues; DWORD cchMaxValue; DWORD cbMaxValueData; DWORD cbSecurityDescriptor; FILETIME ftLastWriteTime; DWORD i; DWORD retCode; TCHAR buffer[MAX_PATH]; DWORD dwSize = sizeof(buffer); // Get the class name and the value count. RegQueryInfoKey(hKey, // key handle achClass, // buffer for class name &cchClassName, // length of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // Enumerate the child keys, until RegEnumKeyEx fails. Then // get the name of each child key and copy it into the list box. for (i = 0, retCode = ERROR_SUCCESS;retCode == ERROR_SUCCESS; i++) { ZeroMemory(&achKey, sizeof(achKey)); cbMaxSubKey = sizeof(achKey); retCode = RegEnumKeyEx(hKey, i, achKey, &cbMaxSubKey, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == (DWORD)ERROR_SUCCESS) { strName.Format( _T("%s"), achKey); strKey = strPath + "\\" + strName; iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_READ, &Key); if (iRet == ERROR_SUCCESS) { ZeroMemory(&buffer, sizeof(buffer)); dwSize = sizeof(buffer); //again iRet = RegQueryValueEx(Key, _T("Display"), NULL, &dwType, (BYTE *)buffer, &dwSize); if (iRet == ERROR_SUCCESS) { strValue.Format(_T("%s"), buffer); m_pszTimeZones.Add( strValue ); } if (iRet == ERROR_SUCCESS)
-
How to use GetTimeZoneInformationok, anyway just closing this item now... just make a new stringarray CStringArray m_pszTimeZonesNames if (iRet == ERROR_SUCCESS) { ZeroMemory(&buffer, sizeof(buffer)); dwSize = sizeof(buffer); //again iRet = RegQueryValueEx(Key, _T("Std"), NULL, &dwType, (BYTE *)buffer, &dwSize); if (iRet == ERROR_SUCCESS) { strValue.Format(_T("%s"), buffer); m_pszTimeZonesNames.Add( strValue ); } have a nice day
-
Programming language indexthat (standard) C is more widely used than C++... yed, that is unfortunately true, a lot of embedded stuff kernel drivers are still c only and old appl which are still maintained use c
-
How to use GetTimeZoneInformationyes... like where strInput = "-09:00" CString strTest; int i; for(i=0;i<=m_pszTimeZones.GetUpperBound();i++) { strTest = m_pszTimeZones.GetAt(i); strTest = strTest.Mid(4,6); if ( strTest == strInput) break; }
-
How to use GetTimeZoneInformationi will use something like this: i will store all zones into m_pszTimeZones and after that it is easy to get information you want .h CStringArray m_pszTimeZones; .cpp void ::TestTM { HKEY hKey, Key; DWORD dwType = REG_SZ; int iRet = 0; CString strName, strValue, strPath, strKey; strPath = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"); iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strPath, 0, KEY_READ, &hKey); if (iRet != ERROR_SUCCESS) return; TCHAR achKey[MAX_PATH]; TCHAR achClass[MAX_PATH] = _T(""); DWORD cchClassName = MAX_PATH; DWORD cSubKeys; DWORD cbMaxSubKey; DWORD cchMaxClass; DWORD cValues; DWORD cchMaxValue; DWORD cbMaxValueData; DWORD cbSecurityDescriptor; FILETIME ftLastWriteTime; DWORD i; DWORD retCode; TCHAR buffer[MAX_PATH]; DWORD dwSize = sizeof(buffer); // Get the class name and the value count. RegQueryInfoKey(hKey, // key handle achClass, // buffer for class name &cchClassName, // length of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // Enumerate the child keys, until RegEnumKeyEx fails. Then // get the name of each child key and copy it into the list box. for (i = 0, retCode = ERROR_SUCCESS;retCode == ERROR_SUCCESS; i++) { ZeroMemory(&achKey, sizeof(achKey)); cbMaxSubKey = sizeof(achKey); retCode = RegEnumKeyEx(hKey, i, achKey, &cbMaxSubKey, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == (DWORD)ERROR_SUCCESS) { strName.Format( _T("%s"), achKey); strKey = strPath + "\\" + strName; iRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKey, 0, KEY_READ, &Key); if (iRet == ERROR_SUCCESS) { ZeroMemory(&buffer, sizeof(buffer)); dwSize = sizeof(buffer); //again iRet = RegQueryValueEx(Key, _T("Display"), NULL, &dwType, (BYTE *)buffer, &dwSize);
-
How to use GetTimeZoneInformationyou wrote: For some offsets it doesn't work which registry keys does it not work ?
-
Printing Class Library : Bottom Marginhi, i suppose that it should be changed into double CPage::SetBottomMargin(double w) { int temp=m_PrtDesc.rc.bottom; if(w > 0) m_PrtDesc.rc.bottom=ConvertToMappedUnits(w,VERTRES); if(w==-1) m_PrtDesc.rc.bottom=m_PrtDesc.n_maxLength; //m_PrtDesc.rc.right=m_PrtDesc.n_maxLength; //previous line return ConvertToInches(temp,VERTRES); } and calling pPage->SetBottomMargin(-1); :cool:
-
How to get chinese text from rtf .i think you are correct perhaps you could use CEdit instead but if not keep in mind RichEditCtrl in Visual C++ 7.0 supports Unicode. To obtain Unicode strings from the RichEditCtrl box, use EM_GETTEXTEX message instead of GetDlgItemText. SendMessage( EM_GETTEXTEX, (LPARAM) &getTextEx, // GETTEXTEX structure (WPARAM) lpszWChar // output WCHAR array ); see also: http://easai.00freehost.com/unicode.html[^]
-
How to get chinese text from rtf .do you have compiled your project as unicode ? if not, make sure that you use preprocessor definitions ( c++ page ) _UNICODE output (link page) - entry point symbol wWinMainCRTStartup further on you could use _T("") instead "" in your code hope it helps
-
Happy Chinese New Year谢谢! dan
-
dcPrint????hi, ON_COMMAND(ID_FILE_PRINT, OnFilePrint) printing goes like this void CMyDialog::OnFilePrint() { CString strValue; int iRet; CPrintInfo Info; //set your info flags PRINTDLG pdsetup; HDC hdc; //get your hdc from pdsetup CDC dc; //dcPrint??? //Attach hdc with dc //set drawing rect //call OnPreparePrinting(&Info); //call OnBeginPrinting(&dc, &Info); DOCINFO docInfo; // make your docinfo if needed //iRet = dc.StartDoc(&docInfo); //iRet = dc.StartPage(); //OnPrepareDC(&dc, &Info); myEditBox.GetWindowText(strValue); dc.TextOut( 200, 200, strValue); //place own coordinates //dc.EndPage(); //dc.EndDoc(); //OnEndPrinting(&dc, &Info); //dc.Detach(); hope it helps dan
-
access pci driver installation through C++i think you can use WMI for that.. see: msdn help on wmi for examples
-
atof conversion in unicode available??hi, CString strCurrent; strCurrent = _T("25.5"); //atof(strCurrent); double dValue = 0; _stscanf(strCurrent, TOFLOAT, &dValue); good luck... dan o
-
CMemDC helphi, why do you use CMemDC, and not directly dc ? HBRUSH oldbrush=(HBRUSH)dc->SelectObject(brush); HPEN oldpen=(HPEN)dc->SelectObject(pen); dc->Rectangle(&r);
-
How to display the item of a treectrl like this?hi, create a imagelist .h CImageList m_cImageList; .cpp populate event() if (1) //bDoThisOnlyOnce m_cImageList.Create(IDB_TREEVIEW, 16, 10, RGB (255, 0, 255)); //IDB_TREEVIEW resource bitmap with a the all icons GetTreeCtrl().SetImageList(&m_cImageList, TVSIL_NORMAL); rootitem = GetTreeCtrl().InsertItem(TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE, _T("RootItem"), ILI_CLOSED_FOLDER, ILI_CLOSED_FOLDER, 0, 0, -1, TVI_ROOT, TVI_SORT ); //ILI_CLOSED_FOLDER, ILI_CLOSED_FOLDER <- item nr of imagelist Add msg .h afx_msg void OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult); .cpp void CMyTreeView::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; HTREEITEM hItem = pNMTreeView->itemNew.hItem; CString string;string = GetPathFromItem (hItem); *pResult = FALSE; int inImage, inSelectedImage; if (pNMTreeView->action == TVE_EXPAND) { if (GetTreeCtrl().GetParentItem (hItem) == NULL ) { GetTreeCtrl().GetItemImage( hItem, inImage, inSelectedImage ); if (inImage == ILI_CLOSED_FOLDER && inSelectedImage == ILI_CLOSED_FOLDER) { GetTreeCtrl().SetItemImage( hItem, ILI_OPEN_FOLDER, ILI_OPEN_FOLDER); } } } else { // pNMTreeView->action == TVE_COLLAPSE if (GetTreeCtrl().GetParentItem (hItem) == NULL) { GetTreeCtrl().GetItemImage( hItem, inImage, inSelectedImage ); if (inImage == ILI_OPEN_FOLDER && inSelectedImage == ILI_OPEN_FOLDER) { GetTreeCtrl().SetItemImage( hItem, ILI_CLOSED_FOLDER, LI_CLOSED_FOLDER); } } } hope it helps dan o hope it helps
-
WMI - How do I use it ? -
Closing Modal Dialoghi, of course is that possible just start a new tread in OnInitDialog() Or just with OnTimer Event of CDialog class and when time is reached/or thread is finished when dialog must close. just call OnOK() or ONCancel() dano
-
How to use Microsoft Layer for Unicode with MFC apphi, Win 9x does not support unicode itself, you must re-write the unicode functions yourself, and all functions/class export the normal char in stead w-char but Inside in your own class/functions w_char could be used.... i think it is very hard to make your program real unicode support for win'9x (perhaps you make a special resource file for translated texts, win'9x has a good support of russian/baltic/other east-european languagues it self, but Asian Languages like chinese / japanese / koreoan / sanskriet is very poor) dan o