したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |

管理人の独り言(プログラミング関連)

1046774さん:2008/12/10(水) 18:24:55 ID:CENbthlg0
#define STRICT 1

#if !defined(UNICODE) && !defined(_UNICODE)
#error UNICODE版でしかコンパイル出来んぞい。
#endif

#include <iostream>
#include <cstdio>
#include <string>
#include <windows.h>
#include <lmcons.h>
#include <tchar.h>

using namespace std;

bool IsFileExist(wstring str){
FILE *file = _wfopen(str.c_str(), L"rb");
if(!file)
return false;
fclose(file);
return true;
}

//user.iniの入っているフォルダを頑張って探す
wstring GetSettingPath(){
WCHAR cur[MAX_PATH + 1];
GetCurrentDirectoryW(sizeof(cur) / sizeof(cur[0]) - 1, cur);

wstring currentPath(cur);

int UseAppData = 0, MultiUser = 1; //デフォルトらしい。:http://www.sleipnir-wiki.jp/index.php?Tips#w534cfdd
if(IsFileExist(currentPath + L"\\Sleipnir.Property")){ //存在するか
UseAppData = (int)GetPrivateProfileIntW(L"Setting", L"UseAppData", UseAppData, (currentPath + L"\\Sleipnir.Property").c_str());
MultiUser = (int)GetPrivateProfileIntW(L"Setting", L"MultiUser", MultiUser, (currentPath + L"\\Sleipnir.Property").c_str());
}

wstring base;
switch(UseAppData){
case 0:{ //Sleipnirインストールフォルダ以下
base = currentPath + L"\\..\\settings";

break;
}

case 1:{ //各ユーザーのApplication Dataフォルダ以下
base = L"%USERPROFILE%\\..";

break;
}

default:
return wstring(L"");
}
switch(MultiUser){
case 0:{ //All Users
base += L"\\All Users";
break;
}

case 1:{
WCHAR userName[UNLEN + 1];
DWORD size = sizeof(userName) / sizeof(userName[0]) - 1;
GetUserNameW(userName, &size);
base += L"\\";
base += userName;
break;
}

default:
return wstring(L"");
}
if(UseAppData == 1){
//TODO;
return wstring(L"");
}

return base;
}

int main(int argc, char **argv){
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); //Sleipnirの起動処理よりも早く
wstring settingPath = GetSettingPath();
if(settingPath == L"") return -1;
wstring userIniPath = settingPath + L"\\setting\\user.ini";

if(IsFileExist(userIniPath))
WritePrivateProfileStringW(L"SmartUpdater", L"LastCheckTime", L"\"14727\"", userIniPath.c_str());
}


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板