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");
编辑不过去,是不是需要什么头文件?

解决方案 »

  1.   

    #include "Winbase.h"
    #pragma comment(lib, "Kernel32.lib")
      

  2.   

    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)
    就这么多啊!
      

  3.   

    #include "Winbase.h"
    #pragma comment(lib, "Kernel32.lib")
    这两个没有用啊!
      

  4.   

    我本来选的是An application supports MFC
      

  5.   

    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;
      

  6.   

    是执行api函数的所在的位置,一般在函数体内!