How do you know if a combination of a path and filename is valid ? I don't want to know if it is an actual existing file but only if it's valid (does not contain any invalid caracters). Also, I do not want to create a file on the disk to know if I'll receive an invalid filename error. So, how can I know if a path + filename combination has a valid syntax ? (example: "C:\folder name\file name.ext" is valid, "C:\folder name\file&?n!.ext" is invalid) I'm using C++ only (no MFC, etc). Thanks a lot ! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/
JC Gauthier
Posts
-
Validate a filename -
Disabling a button using ATLExcellent ! This is exactly what I was looking for :-D Thanks for your input. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/
-
Disabling a button using ATLIs there a way to enable/disable a button whitout using MFC ? I am not really familliar with this type of operation. I've done it successfully for edit control :
// Enable ::SendDlgItemMessage(hwndDlg, IDC_KEYPAIRNEWFILENAME, WM_ENABLE, TRUE, 0); // Disable ::SendDlgItemMessage(hwndDlg, IDC_KEYPAIRNEWFILENAME, WM_ENABLE, FALSE, 0);
and was expectiong something similar for buttons but everything I tried was unsuccessfull. Thanks. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/ -
How ???Security holes in IE or somebody else have been using your computer :) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/
-
Problem converting a CComBSTR to LPCTSTR with CW2CT:~ even with 1024 it doesn't work
TCHAR pszBuf[1024] = "";// Message buffer
maybe there is something else I need to do. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= J.-C. Gauthier - http://www.grandmenhir.com/
-
Problem converting a CComBSTR to LPCTSTR with CW2CToops sorry, I kinda didn't notice I was in the wrong forum :) =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= JiCi - http://www.grandmenhir.com/
-
Problem converting a CComBSTR to LPCTSTR with CW2CTI have a problem converting a CComBSTR to LPCTSTR with CW2CT. Eveything works fine until my CComBSTR gets around 64 caracters... then the result of the convertion is a long "corrupted" string: "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ...." Please help me ! :(( ----- See comments between /* */ for more info -----
LRESULT CListBoxDlg::OnBnClickedBtngetselitems(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
LPCTSTR sTitle; // Message box title
int arrSelList[12]; // Message buffer
TCHAR pszBuf[128] = "";// Message buffer
int iMaxNum = 12; // Max number of selected items
LRESULT iSelCount = 0; // Total selected items in the list
LPCTSTR sMsg = 0; // Message to put in the message box
CComBSTR bsMessage; // Message accumulatoriSelCount = this->SendDlgItemMessage(IDC\_AVSCODES, LB\_GETSELITEMS, WPARAM(iMaxNum), LPARAM(arrSelList)); if (iSelCount != LB\_ERR) { bsMessage.Append("You have selected the fields: "); \_stprintf(pszBuf, "%li", arrSelList\[0\]); bsMessage.Append(pszBuf); for (int i = 1; i < iSelCount; i++) { bsMessage.Append(", "); \_stprintf(pszBuf, "%li", arrSelList\[i\]); bsMessage.Append(pszBuf); } bsMessage.Append("."); /\* The following line will fails if bsMessage.m\_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11." But will not fail if it bsMessage.m\_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10." (4 caracter less) but long size is not suppose the cause problems with ATL 7.0 compared to ATL 3.0 \*/ sMsg = CW2CT(bsMessage.m\_str); /\* // The following two lines makes it work fine but USES\_CONVERSION is not supposed // to be needed with ATL 7.0 USES\_CONVERSION; sMsg = W2CT(bsMessage.m\_str);\*/ sTitle = \_T("Selected Items List"); ::MessageBox(this->m\_hWnd, sMsg, sTitle, MB\_OK); } return 0;
}
-
Problem converting a CComBSTR to LPCTSTR with CW2CTI have a problem converting a CComBSTR to LPCTSTR with CW2CT. Eveything works fine until my CComBSTR gets around 64 caracters... then the result of the convertion is a long "corrupted" string: "îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþ" Please help me ! :(( ----- See comments between /* */ for more info ----- LRESULT CListBoxDlg::OnBnClickedBtngetselitems(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { LPCTSTR sTitle; // Message box title int arrSelList[12]; // Message buffer TCHAR pszBuf[128] = "";// Message buffer int iMaxNum = 12; // Max number of selected items LRESULT iSelCount = 0; // Total selected items in the list LPCTSTR sMsg = 0; // Message to put in the message box CComBSTR bsMessage; // Message accumulator iSelCount = this->SendDlgItemMessage(IDC_AVSCODES, LB_GETSELITEMS, WPARAM(iMaxNum), LPARAM(arrSelList)); if (iSelCount != LB_ERR) { bsMessage.Append("You have selected the fields: "); _stprintf(pszBuf, "%li", arrSelList[0]); bsMessage.Append(pszBuf); for (int i = 1; i < iSelCount; i++) { bsMessage.Append(", "); _stprintf(pszBuf, "%li", arrSelList[i]); bsMessage.Append(pszBuf); } bsMessage.Append("."); /* The following line will fails if bsMessage.m_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11." But will not fail if it bsMessage.m_str contains: "You have selected the fields: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10." (4 caracter less) but long size is not suppose the cause problems with ATL 7.0 c