请问下面这段代码中,logFileName初始为"",调用OpenFile前其值变为用户输入的文件名,但未见对其赋值,这是为什么?static char logFileName[250];void logStart()
{
OPENFILENAME ofn;
OFSTRUCT of; /* If currently logging, close file
*/
if (logging)
logStop(); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = termGetWnd();
ofn.lpstrFilter = "Text Files (*.LOG)\0*.LOG\0All Files (*.*)\0*.*\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = logFileName;
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = logFileTitle;
ofn.nMaxFileTitle = _MAX_PATH;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "LOG";
ofn.Flags = 0; /* Ask user for file to log messages into
*/
if (!GetOpenFileName(&ofn))
return; /* Open the new log file
*/
logFh = OpenFile(logFileName, &of, OF_WRITE|OF_CREATE);
if (logFh < 0) {
logError("Cannot create log file");
return;
} /* Tell application window to update its title. This will then
* call logGetTitle to determine the log filename portion of the
* title.
*/
telnetSetTitle(); /* Flag that we are currently logging to a file
*/
logging = TRUE;
}
{
OPENFILENAME ofn;
OFSTRUCT of; /* If currently logging, close file
*/
if (logging)
logStop(); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = termGetWnd();
ofn.lpstrFilter = "Text Files (*.LOG)\0*.LOG\0All Files (*.*)\0*.*\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFile = logFileName;
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrInitialDir = NULL;
ofn.lpstrFileTitle = logFileTitle;
ofn.nMaxFileTitle = _MAX_PATH;
ofn.lpstrTitle = NULL;
ofn.lpstrDefExt = "LOG";
ofn.Flags = 0; /* Ask user for file to log messages into
*/
if (!GetOpenFileName(&ofn))
return; /* Open the new log file
*/
logFh = OpenFile(logFileName, &of, OF_WRITE|OF_CREATE);
if (logFh < 0) {
logError("Cannot create log file");
return;
} /* Tell application window to update its title. This will then
* call logGetTitle to determine the log filename portion of the
* title.
*/
telnetSetTitle(); /* Flag that we are currently logging to a file
*/
logging = TRUE;
}
解决方案 »
- 在MFC中使用boost::tregex_iterator的问题
- 神奇!::PostMessage(pSrvSock->m_hWnd, WM_SOCK_MSG, 0, FD_READ);可以接收消息,但WSAAsyncSelect(ServerSock, pSrvS
- 使用Drag and Drop实现拖拽功能,怎样显示跟随鼠标的图片?
- 请前辈指点一下 打印 预览 中,文本如何 换行?
- 高分求问 分可以加 因为不太懂MFC 有源代码 IBM 的 一个客户端
- 简单的BOOL型数组初始化问题
- 高分,求RTP和RTCP和SIP等方面的资料啊???????????????
- 在线等待,winsock Server 与 client 通讯程序原码!
- 谁能帮我解决这个小问题,我一定送他100分!!!
- SetDialogBkColor为什么不行?
- 文本转语音 TTS(MS Speech SDK)问题??
- 请问免费软件发布到哪儿可以自由下载?谢谢啦
"All Files (*.*)|*.*||", NULL);
if(IDOK != dlg.DoModal())
return;
m_Pathname = dlg.GetPathName();
这样多好啊! 弄的那么麻烦
Pointer to a buffer that contains a filename used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, filename, and extension of the selected file. 指出 GetOpenFileName 函数成功返回后lpstrFile 存储的是获取的文件名全路径而你的函数OpenFile 前调用了 GetOpenFileName 函数 所以到调用 OpenFile 时logFileName已经有值了。