char szTemp[MAX_PATH];
// Setup the .ini file to use
free((void*)m_pszProfileName);
GetModuleFileName(NULL,szTemp,sizeof(szTemp));
m_pszProfileName=_tcsdup(_T(SplitFileName(szTemp,DRIVE|PATH|FNAME)+".ini"));上面语句是我看一个例子上的!找遍project也没发现m_pszProfileName的定义!
但free释放啥呀?
_tcsdup是啥啊,起什么作用啊?
_T是啥啊,起什么作用啊?
// Setup the .ini file to use
free((void*)m_pszProfileName);
GetModuleFileName(NULL,szTemp,sizeof(szTemp));
m_pszProfileName=_tcsdup(_T(SplitFileName(szTemp,DRIVE|PATH|FNAME)+".ini"));上面语句是我看一个例子上的!找遍project也没发现m_pszProfileName的定义!
但free释放啥呀?
_tcsdup是啥啊,起什么作用啊?
_T是啥啊,起什么作用啊?
解决方案 »
- 关于自定义控件ListBox被遮挡的问题?
- 请问我写的某个存储过程为什么不能修改???有个锁状的小标志!!!!!
- 关于PreCreateWindow
- 如何将xml文件转换成access 数据库中的一个表
- 看上去是简单问题,可结果就是不对,不解,请帮忙,说说,在线等............
- 请问如何使用csting和html生成网页?
- How to read a bitmap from rescource? - Easy and quick
- 什么样的钩子能够修改消息?
- 关于CHtmlView::Navigate2函数的使用疑问?
- 类里的变量,线程获取不到?
- 放分200, 今天回家过年了。
- 为什么我的联机帮助文件.chm不能显示图片
_tcsdup _strdup _mbsdup _wcsdup
Because _strdup calls malloc to allocate storage space for the copy of strSource, it is good practice always to release this memory by calling the free routine on the pointer returned by the call to _strdup.
_tcsdup _strdup _mbsdup _wcsdup
Because _strdup calls malloc to allocate storage space for the copy of strSource, it is good practice always to release this memory by calling the free routine on the pointer returned by the call to _strdup.
char对应的操作函数以str开头,如strlen(),w_char对应的则以_wcs开头,如_wcslen()
对应于TCHAR,_tcs开头的函数据编译选项确定是str还是_wcs,----它们本质上只是个宏而已。
_tcsdup():复制字符串。
CWinApp Overview | Class Members | Hierarchy Chart | CWinApp::GetProfileString | CWinApp::GetProfileInt | CWinApp::WriteProfileInt | CWinApp::WriteProfileStringContains the name of the application's .INI file.
LPCTSTR m_pszProfileName;
Res
m_pszProfileName is a public variable of type const char*.
Note If you assign a value to m_pszProfileName, it must be dynamically allocated on the heap. The CWinApp destructor calls free( ) with this pointer. You many want to use the _tcsdup( ) run-time library function to do the allocating. Also, free the memory associated with the current pointer before assigning a new value. For example:
//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszProfileName);
//Change the name of the .INI file.
//The CWinApp destructor will free the memory.
m_pszProfileName=_tcsdup(_T("d:\\somedir\\myini.ini"));
使用后,用free释放