Button--->中加入事件
FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); this.txtPath.Text = path.SelectedPath;
TextBox-->更改名稱 txtPath
測試環境 :c#
Button--->中加入事件
FolderBrowserDialog path = new FolderBrowserDialog(); path.ShowDialog(); this.txtPath.Text = path.SelectedPath;
TextBox-->更改名稱 txtPath
測試環境 :c#
CString FileName = L"C:\\123.txt";
int buf = 0;
buf = _waccess(FileName , 04);
if (buf != 0) { AfxMessageBox(L"Files error"); return false; }測試環境:MFC
// Example code
CFolderPickerDialog m_dlg;
CString m_Folder;
m_dlg.m_ofn.lpstrTitle = _T("Put your title here");
m_dlg.m_ofn.lpstrInitialDir = _T("C:\\");
if (m_dlg.DoModal() == IDOK) {
m_Folder = m_dlg.GetPathName(); // Use this to get the selected folder name
// after the dialog has closed
// May need to add a '\' for usage in GUI and for later file saving,
// as there is no '\' on the returned name
m_Folder += _T("\\");
UpdateData(FALSE); // To show updated folder in GUI
// Debug
TRACE("\n%S", m_Folder);
}
// End of example
測試環境:MFC
CComboBox m_cCUTCOMBO;
在*.cpp中新增
需新增在 DoDataExchange(CDataExchange* pDX) 中
//控制項
DDX_Control(pDX, IDC_COMBCUT, m_cCUTCOMBO);測試環境:MFC
using System.IO;
取得程式當下檔案目錄資訊: string sPath = this.GetType().Assembly.Location;
string filename = @"C:\Users\123.text"; if (File.Exists(filename)) { MessageBox.Show("取得檔名(不包含附檔名)" + Path.GetFileNameWithoutExtension(filename)); MessageBox.Show("取得副檔名:" + Path.GetExtension(filename)); MessageBox.Show("目錄資料夾路徑:" + Path.GetDirectoryName(filename)); MessageBox.Show("資料根目錄:" + Path.GetPathRoot(filename)); MessageBox.Show("取得路徑:" + Path.GetFullPath(filename)); }
測試環境:c#.net 2015
CString csbuf; USES_CONVERSION; char* chPath = T2A((LPTSTR)(LPCTSTR)csbuf);
測試環境 mfc Unicode
宣告句柄與類定義的指標 宣告一個新函式替代原來的
在初始化的地方
使用"LoadLibrary"呼叫dll
使用"GetProcAddress"定義函式
最後再要使用的地方 直接使用替代的函式 即可
==============================以下範例================================
HMODULE hmod; typedef DXF_PARSE*(*MyAdd)(); typedef DXF_PREVIEW*(*MyAdd2)(); MyAdd Add; MyAdd2 Add2;
寫在init
BOOL CDxftoNcfileDlg::OnInitDialog() { CDialogEx::OnInitDialog();// TODO: 在此加入額外的初始設定 hmod = LoadLibrary(L"DxfLib2.dll"); //load dll if (hmod == NULL) { return 0; } Add = (MyAdd)GetProcAddress(hmod, "GetParsesPtr"); if (!Add) { MessageBox(L"error_GetParsesPtr"); return 0; } Add2 = (MyAdd2)GetProcAddress(hmod, "GetPreviewsPtr"); if (!Add2) { MessageBox(L"error_GetPreviewsPtr"); return 0; }return TRUE; // 傳回 TRUE,除非您對控制項設定焦點}再欲使用的地方加上直接替換add()add2()測試環境:MFC
CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) CONVERT style參數說明 1 (expression為 money 或 smallmoney型別): 0 : 預設,保留小數位後兩位,並四捨...