请各位大哥帮忙,读取ini文件错误!

AndyFunction 2004-11-01 03:30:28
GetPrivateProfileString("CONNECTION","Sourse","0",Sourse.GetBuffer(MAX_PATH),128,"E:\\Cer\\edi_init.ini");
GetPrivateProfileString("CONNECTION","UserID","0",UserID.GetBuffer(MAX_PATH),128,"E:\\Cer\\edi_init.ini");
GetPrivateProfileString("CONNECTION","password","0",password.GetBuffer(MAX_PATH),128,"E:\\Cer\\edi_init.ini");
GetPrivateProfileString("CONNECTION","DBdate","0",DBdate.GetBuffer(MAX_PATH),128,"E:\\Cer\\edi_init.ini");
编辑不过去,是不是需要什么头文件?
...全文
188 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanaichun 2004-11-02
  • 打赏
  • 举报
回复
是执行api函数的所在的位置,一般在函数体内!
hanaichun 2004-11-02
  • 打赏
  • 举报
回复
是不是你放的位置不对!
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
怎么不可以啊!
broadoceans 2004-11-01
  • 打赏
  • 举报
回复
当然是创建工程的时候选了
菜牛 2004-11-01
  • 打赏
  • 举报
回复
CString::GetBuffer()返回的是LPCTSTR。
需要自己定义LPTSTR buffer来作为接收返回值的缓冲区。
LPTSTR buffer = new TCHAR[MAX_PATH];
GetPrivateProfileString("CONNECTION","Sourse","0",buffer,MAX_PAT,"E:\\Cer\\edi_init.ini");
Sourse = buffer;
GetPrivateProfileString("CONNECTION","UserID","0",buffer,MAX_PAT,"E:\\Cer\\edi_init.ini");
UserID = buffer;
GetPrivateProfileString("CONNECTION","password","0",buffer,MAX_PAT,"E:\\Cer\\edi_init.ini");
password = buffer;
GetPrivateProfileString("CONNECTION","DBdate","0",buffer,MAX_PAT,"E:\\Cer\\edi_init.ini");
DBdate = buffer;
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
我本来选的是An application supports MFC
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
怎么选?在哪里选?
broadoceans 2004-11-01
  • 打赏
  • 举报
回复
选择MFC支持就行了
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
控制台程序!!!
huwei001982 2004-11-01
  • 打赏
  • 举报
回复
是 SDK 程序吗?
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
#include "Winbase.h"
#pragma comment(lib, "Kernel32.lib")
这两个没有用啊!
AndyFunction 2004-11-01
  • 打赏
  • 举报
回复
E:\Cer\Cer.cpp(75) : error C2501: 'GetPrivateProfileStringA' : missing storage-class or type specifiers
E:\Cer\Cer.cpp(75) : error C2373: 'GetPrivateProfileStringA' : redefinition; different type modifiers
d:\program files\microsoft visual studio\vc98\include\winbase.h(4894) : see declaration of 'GetPrivateProfileStringA'
E:\Cer\Cer.cpp(75) : error C2078: too many initializers
E:\Cer\Cer.cpp(75) : error C2440: 'initializing' : cannot convert from 'char [16]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\Cer\Cer.cpp(76) : error C2501: 'GetPrivateProfileStringA' : missing storage-class or type specifiers
E:\Cer\Cer.cpp(76) : error C2373: 'GetPrivateProfileStringA' : redefinition; different type modifiers
d:\program files\microsoft visual studio\vc98\include\winbase.h(4894) : see declaration of 'GetPrivateProfileStringA'
E:\Cer\Cer.cpp(76) : error C2078: too many initializers
E:\Cer\Cer.cpp(76) : error C2440: 'initializing' : cannot convert from 'char [16]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\Cer\Cer.cpp(77) : error C2065: 'password' : undeclared identifier
E:\Cer\Cer.cpp(77) : error C2228: left of '.GetBuffer' must have class/struct/union type
E:\Cer\Cer.cpp(77) : error C2501: 'GetPrivateProfileStringA' : missing storage-class or type specifiers
E:\Cer\Cer.cpp(77) : error C2373: 'GetPrivateProfileStringA' : redefinition; different type modifiers
d:\program files\microsoft visual studio\vc98\include\winbase.h(4894) : see declaration of 'GetPrivateProfileStringA'
E:\Cer\Cer.cpp(77) : error C2078: too many initializers
E:\Cer\Cer.cpp(77) : error C2440: 'initializing' : cannot convert from 'char [16]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
E:\Cer\Cer.cpp(78) : error C2501: 'GetPrivateProfileStringA' : missing storage-class or type specifiers
E:\Cer\Cer.cpp(78) : error C2373: 'GetPrivateProfileStringA' : redefinition; different type modifiers
d:\program files\microsoft visual studio\vc98\include\winbase.h(4894) : see declaration of 'GetPrivateProfileStringA'
E:\Cer\Cer.cpp(78) : error C2078: too many initializers
E:\Cer\Cer.cpp(78) : error C2440: 'initializing' : cannot convert from 'char [16]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
Creating browse info file...

Cer.exe - 18 error(s), 0 warning(s)
就这么多啊!
flyelf 2004-11-01
  • 打赏
  • 举报
回复
什么错误信息?
broadoceans 2004-11-01
  • 打赏
  • 举报
回复
#include "Winbase.h"
#pragma comment(lib, "Kernel32.lib")

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧