注册 登录
编程论坛 C++教室

GetPrivateProfileSectionNames一直返回0

魔城侠客 发布于 2012-04-21 14:12, 2175 次点击
今天用GetPrivateProfileSectionNames获取ini文件中所有section名称时,一直返回0,而且数组中也没有东西,这是如何?
    char *path = "D:\\abc.ini";
    DWORD secLen = 100;
    char section[100];
    //读取所有section
    int ret = GetPrivateProfileSectionNames((LPWSTR)section,secLen,(LPCWSTR)path);
    cout<<ret<<endl;
    system("pause");
    return 0;
代码是上面那样。
2 回复
#2
rjsp2012-04-21 15:22
(LPWSTR)section 都是什么呀?你直接写
(百万美金)section
岂不是可以回家享福去了?

要么用 TCHAR数组,用 GetPrivateProfileSectionNames 函数
要么用 char数组,用 GetPrivateProfileSectionNamesA 函数
要么用 wchar_t数组,用 GetPrivateProfileSectionNamesW 函数
#3
魔城侠客2012-04-21 15:33
啊,对C++不了解,谢谢版主了。搞定了
1