:),把SQL Server Name存放到ini文件里面,只需要改文件里面的servername就行了。不需要改程序。
密码怎么办? ini文件用什么方法读? 没有别的办法?
INI文件通过Tinifile类来读取。
存入到注册表里,保密好 TRegistry
function GetRegistryValue(KeyName: string): string; var Registry: TRegistry; begin Registry := TRegistry.Create(KEY_READ); try Registry.RootKey = HKEY_LOCAL_MACHINE; // False because we do not want to create it if it doesn't exist Registry.OpenKey(KeyName, False); Result := Registry.ReadString('VALUE1'); finally Registry.Free; end; end;
ini文件用什么方法读?
没有别的办法?
TRegistry
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ);
try
Registry.RootKey = HKEY_LOCAL_MACHINE;
// False because we do not want to create it if it doesn't exist
Registry.OpenKey(KeyName, False);
Result := Registry.ReadString('VALUE1');
finally
Registry.Free;
end;
end;
用winnt集成安全设置可以吗?他和用‘指定的名称和密马’哪一个更好?
对.INI文件的操作可以通过Windows API函数来实现附函数:
GetPrivateProfileInt 从.INI文件中取得指定节指定键名的整型数信息
GetPrivateProfileSection 从.INI文件中取得指定节的信息
GetPrivateProfileSectionNames 从.INI文件中取得所有节的名称
GetPrivateProfileString 从.INI文件中取得指定节指定键名的字符串信息
GetPrivateProfileStruct 从.INI文件中取得指定节指定键名的结构数据信息
WritePrivateProfileSection 往.INI文件中写入指定节指定键名的整型数信息
WritePrivateProfileString 往.INI文件中写入指定节指定键名的字符串信息
WritePrivateProfileStruct 往.INI文件中写入指定节指定键名的结构数据信息