Seeker's Memo

個人的で技術的かもしれないメモがメインのブログです。http://seekers.hatenablog.jp/about

Win

C/C++言語(Windows用)で、それが管理者権限で実行されているかプログラム内から確認したい時のサンプル

#include <windows.h> #include <tchar.h> #pragma comment(lib, "kernel32") #pragma comment(lib, "user32") #pragma comment(lib, "advapi32") //自作関数定義 BOOL IsAnAdmin(VOID){ BOOL b = FALSE; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; PSID Ad</tchar.h></windows.h>…

C/C++言語でWindowsの環境変数/値を取得/列挙する

getenv-win.cpp #include <stdio.h> #include <locale.h> #include <stdlib.h> #include <windows.h> #include <tchar.h> int _tmain(const int argc, const TCHAR *argv[]){ _tsetlocale(LC_ALL, _T("")); // 起動引数のチェック if(argc >= 2){ const int BUFFER_SIZE = 2048;//よくわからんが、大きめにバッ</tchar.h></windows.h></stdlib.h></locale.h></stdio.h>…