谢谢。
10 个解决方案
#1
估计你的GetPrivateProfileString的最后一个参数:文件名称,你没有传递全路径
#2
如果不是全路径,在win98下,该api可能首先寻找的地方是windows的系统目录
#3
Windows 95: Although lpDefault is declared as a constant parameter, the system strips any trailing blanks by inserting a null character into the lpDefault string before copying it to the lpReturnedString buffer.
Windows NT: The system does not modify the lpDefault string. This means that if the default string contains trailing blanks, the lpReturnedString and lpDefault strings will not match when compared using the lstrcmp function.
Windows NT: The system does not modify the lpDefault string. This means that if the default string contains trailing blanks, the lpReturnedString and lpDefault strings will not match when compared using the lstrcmp function.
#4
关注一下,同时帮你顶
#5
TCHAR *path = new char[MAX_PATH+1];
GetModuleFileName(::GetModuleHandle(NULL),path,MAX_PATH);
CString INIFilePath = path;
INIFilePath.TrimRight("\\AccessControlService.exe");
g_ExeFileDirectory = INIFilePath + "\\AlarmManager.exe" ;
CString INIFilePathAndName = INIFilePath + "\\Service.INI" ;
if(!PathFileExists(INIFilePathAndName) )
{
::MessageBox(NULL,"配置文件不存在,AccessControlService服务不能运行","AccessControlService提示信息",MB_OK | 0x00200000L | MB_ICONASTERISK);
return false;
}
// 读取数据库参数
GetPrivateProfileString( "DataBase","ServerName","",ServerName,sizeof(ServerName),INIFilePathAndName );
GetPrivateProfileString( "DataBase","DBName","",DBName,sizeof(DBName),INIFilePathAndName );
GetModuleFileName(::GetModuleHandle(NULL),path,MAX_PATH);
CString INIFilePath = path;
INIFilePath.TrimRight("\\AccessControlService.exe");
g_ExeFileDirectory = INIFilePath + "\\AlarmManager.exe" ;
CString INIFilePathAndName = INIFilePath + "\\Service.INI" ;
if(!PathFileExists(INIFilePathAndName) )
{
::MessageBox(NULL,"配置文件不存在,AccessControlService服务不能运行","AccessControlService提示信息",MB_OK | 0x00200000L | MB_ICONASTERISK);
return false;
}
// 读取数据库参数
GetPrivateProfileString( "DataBase","ServerName","",ServerName,sizeof(ServerName),INIFilePathAndName );
GetPrivateProfileString( "DataBase","DBName","",DBName,sizeof(DBName),INIFilePathAndName );
#6
保证可以,你该好好看看你的用法是否有哪块不对
#7
关键是看一看第三个参数,你是不是使用了NULL,应该改成"",这样就对了,我就是这么解决的,我跟你遇到的情况一样,2000下可用,98下不可用.
#8
To retrieve a string from the Win.ini file, use the GetProfileString function.
#9
检查参数,写ini文件要仔细
#10
检查你写入到INI文件里的值,如果有特殊符号,就要注意可能读不全,如Rev_,只会读出前三个字符Rev。处理这种情况的办法是用在写入时用""把值封装起来,即"Rev_",在读的时候就可以完全读出了。
#1
估计你的GetPrivateProfileString的最后一个参数:文件名称,你没有传递全路径
#2
如果不是全路径,在win98下,该api可能首先寻找的地方是windows的系统目录
#3
Windows 95: Although lpDefault is declared as a constant parameter, the system strips any trailing blanks by inserting a null character into the lpDefault string before copying it to the lpReturnedString buffer.
Windows NT: The system does not modify the lpDefault string. This means that if the default string contains trailing blanks, the lpReturnedString and lpDefault strings will not match when compared using the lstrcmp function.
Windows NT: The system does not modify the lpDefault string. This means that if the default string contains trailing blanks, the lpReturnedString and lpDefault strings will not match when compared using the lstrcmp function.
#4
关注一下,同时帮你顶
#5
TCHAR *path = new char[MAX_PATH+1];
GetModuleFileName(::GetModuleHandle(NULL),path,MAX_PATH);
CString INIFilePath = path;
INIFilePath.TrimRight("\\AccessControlService.exe");
g_ExeFileDirectory = INIFilePath + "\\AlarmManager.exe" ;
CString INIFilePathAndName = INIFilePath + "\\Service.INI" ;
if(!PathFileExists(INIFilePathAndName) )
{
::MessageBox(NULL,"配置文件不存在,AccessControlService服务不能运行","AccessControlService提示信息",MB_OK | 0x00200000L | MB_ICONASTERISK);
return false;
}
// 读取数据库参数
GetPrivateProfileString( "DataBase","ServerName","",ServerName,sizeof(ServerName),INIFilePathAndName );
GetPrivateProfileString( "DataBase","DBName","",DBName,sizeof(DBName),INIFilePathAndName );
GetModuleFileName(::GetModuleHandle(NULL),path,MAX_PATH);
CString INIFilePath = path;
INIFilePath.TrimRight("\\AccessControlService.exe");
g_ExeFileDirectory = INIFilePath + "\\AlarmManager.exe" ;
CString INIFilePathAndName = INIFilePath + "\\Service.INI" ;
if(!PathFileExists(INIFilePathAndName) )
{
::MessageBox(NULL,"配置文件不存在,AccessControlService服务不能运行","AccessControlService提示信息",MB_OK | 0x00200000L | MB_ICONASTERISK);
return false;
}
// 读取数据库参数
GetPrivateProfileString( "DataBase","ServerName","",ServerName,sizeof(ServerName),INIFilePathAndName );
GetPrivateProfileString( "DataBase","DBName","",DBName,sizeof(DBName),INIFilePathAndName );
#6
保证可以,你该好好看看你的用法是否有哪块不对
#7
关键是看一看第三个参数,你是不是使用了NULL,应该改成"",这样就对了,我就是这么解决的,我跟你遇到的情况一样,2000下可用,98下不可用.
#8
To retrieve a string from the Win.ini file, use the GetProfileString function.
#9
检查参数,写ini文件要仔细
#10
检查你写入到INI文件里的值,如果有特殊符号,就要注意可能读不全,如Rev_,只会读出前三个字符Rev。处理这种情况的办法是用在写入时用""把值封装起来,即"Rev_",在读的时候就可以完全读出了。