Ben D kullanarak kayıt defterinde bazı değerleri değiştirmeye çalışıyorum ama bana aşağıdaki hata veren tutar: C# kodun aynısını yazarsanızWindows Kayıt Sayı
Value cannot be set
Ancak o zaman çalışır. D'deki kayıt defteri modülü ile ilgili bir sorun mu var, yoksa onu kullanma şeklimdeki bir sorun mu var?
Eğer SOFTWARE\WOW6432Node
kayıt defteri girdisi var gibi D
module main;
import std.windows.registry;
import std.stdio;
import core.thread;
void main() {
string languageName = "English";
string languageCode = "en_uk";
const uint languageValue = 0x00000001;
writefln("Name '%s' Code '%s' Value '%s'", languageName, languageCode, languageValue);
writeln("Press ENTER to change language.");
readln();
writefln("Changing language of Sims 2 to '%s' ...", languageName);
Thread.sleep(dur!("msecs")(2000));
string keyName;
try {
enum versions = [
"",
"Apartment Life",
"Bon Voyage",
"Celebration Stuff",
"Family Fun Stuff",
"Free Time",
"Fun with Pets Collection",
"Glamour Life Stuff",
"H M Fashion Stuff",
"IKEA Home Stuff",
"Kitchen & Bath Interior Design Stuff",
"Mansion and Garden Stuff",
"Nightlife",
"Open For Business",
"Pets",
"Seasons",
"Teen Style Stuff",
"University"
];
foreach (simsVersion; versions) {
keyName = "SOFTWARE\\Wow6432Node\\EA GAMES\\The Sims 2";
if (simsVersion && simsVersion.length)
keyName ~= " " ~ simsVersion;
// main
{
scope auto key = Registry.localMachine.getKey(keyName);
key.setValue("Language", languageName);
key.setValue("Locale", languageCode);
key.flush();
}
// sub
{
keyName ~= "\\1.0";
scope auto key = Registry.localMachine.getKey(keyName);
key.setValue("Language", languageValue);
key.setValue("LanguageName", languageName);
key.flush();
}
writefln("Changed language of '%s' ...", simsVersion);
}
writeln("Success...");
Thread.sleep(dur!("msecs")(2000));
}
catch (Throwable t) {
writefln("Key Entry: '%s'", keyName);
writeln(t);
readln();
}
}
C#
class Program
{
public static void Main(string[] args)
{
const string languageName = "English";
const string languageCode = "en_uk";
const uint languageValue = 0x00000001;
string[] versions = new string[]
{
"",
"Apartment Life",
"Bon Voyage",
"Celebration Stuff",
"Family Fun Stuff",
"FreeTime",
"Fun with Pets Collection",
"Glamour Life Stuff",
"H M Fashion Stuff",
"IKEA Home Stuff",
"Kitchen & Bath Interior Design Stuff",
"Mansion and Garden Stuff",
"Nightlife",
"Open For Business",
"Pets",
"Seasons",
"Teen Style Stuff",
"University"
};
const string mainKey = @"SOFTWARE\Wow6432Node\EA GAMES\The Sims 2";
string keyName = "";
try
{
Console.WriteLine("Name '{0}' Code '{1}' Value '{2}'", languageName, languageCode, languageValue);
Console.WriteLine("Press ENTER to change language.");
Console.ReadLine();
Console.WriteLine("Changing language of Sims 2 to '{0}' ...", languageName);
Thread.Sleep(2000);
foreach (var simsVersion in versions)
{
if (!string.IsNullOrWhiteSpace(simsVersion))
keyName = mainKey + " " + simsVersion;
else
keyName = mainKey;
// main
{
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
key.SetValue("Language", languageName);
key.SetValue("Locale", languageCode);
key.Close();
}
// sub
{
keyName += "\\1.0";
var key = Registry.LocalMachine.OpenSubKey(keyName, true);
key.SetValue("Language", languageValue);
key.SetValue("LanguageName", languageName);
key.Close();
}
Console.WriteLine("Changed language of '{0}' ...", simsVersion);
}
Console.WriteLine("Success...");
Thread.Sleep(2000);
}
catch (Exception e)
{
Console.WriteLine("Key: '{0}'", keyName);
Console.WriteLine(e);
Console.ReadLine();
}
}
}
D kodunuz 64 bit olarak mı derlendi? –
Ayrıca, programı yönetici olarak mı çalıştırıyorsunuz? –
32bit ile derliyorum ve yönetici olarak çalışıyorum. – Bauss