- 759 名前:win32 mailto:sage [2007/01/13(土) 03:06:33 ]
- とりあえず動くようだ。
// Visual C/C++ windows32 project #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <shlobj.h>//needs shell32.lib int main(int argc, char * argv[]) { FILE * fdHosts; char szSystemPath[MAX_PATH]; char szHostsPath[MAX_PATH]; SHGetFolderPath(NULL,CSIDL_SYSTEM , NULL, 0, szSystemPath); sprintf( szHostsPath, "%s\\drivers\\etc\\hosts" ,szSystemPath ); printf( szHostsPath ); fdHosts = fopen( szHostsPath, "a" );//例外処理は省略 fprintf( fdHosts, "#\n" ); fprintf( fdHosts, "pc10.2ch.net 206.223.148.200\n" ); fprintf( fdHosts, "pc9.2ch.net 206.223.147.60\n" ); //のこりのサーバ // // fclose( fdHosts ); return 0; }
|

|