我知道这是一个简单的问题,但我很习惯使用Borland和包装器,所以这对我来说是一种新的方法.有人可以简单地告诉我如何打开一个只能从visual studio c控制台应用程序获取.obj文件的OpenDia
非常感谢!
除了入口点(“GUI”应用程序中的WinMain)之外,控制台应用程序和GUI应用程序之间没有任何区别,如果没有从控制台启动,控制台应用程序将在启动期间打开控制台窗口.所有Win32 API都可用,因此您需要使用GetOpenFileName调用,如下所示:
OPENFILENAME ofn; char *FilterSpec ="Object Files(*.obj)\0*.obj\0Text Files(*.txt)\0*.txt\0All Files(*.*)\0*.*\0"; char *Title ="Open...."; char szFileName[MAX_PATH]; char szFileTitle[MAX_PATH]; int Result; *szFileName = 0; *szFileTitle = 0; /* fill in non-variant fields of OPENFILENAME struct. */ ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = GetFocus(); ofn.lpstrFilter = FilterSpec; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 0; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.lpstrInitialDir = "."; // Initial directory. ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrTitle = Title; ofn.lpstrDefExt = default_extension; ofn.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; if (!GetOpenFileName ((LPOPENFILENAME)&ofn)) { return (-1); // Failed or cancelled } else { this->filename.Set(szFileName); }