【初心者歓迎】C/C++室 Ver.48【環境依存OK】at TECH【初心者歓迎】C/C++室 Ver.48【環境依存OK】 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト403:デフォルトの名無しさん 08/02/11 11:08:24 なんで CoCreateInstance 使ってないの? 404:デフォルトの名無しさん 08/02/11 11:21:28 CoCreateInstanceはレジストリに登録しないと使えないと、どこかで見た記憶があり 更にDirectXのレジストリ登録を見る限り、musicしかなかったので この方法でいけるんじゃないかと思っていました CoCreateInstanceの方で調べて試してみます 指摘ありがとうございました 405:388 できました 08/02/11 11:27:38 #include <iostream> #include <vector> #include <string> #include <windows.h> using namespace std; class dirserch{ vector <string> dirname; vector <int > dir[300]; string path[300]; int n; WIN32_FIND_DATA fd; HANDLE hd; public: dirserch(char *ch); int next(string &str); }; main(){ dirserch dr("c:\\windows"); string str; while(dr.next(str))cout<<str<<endl;} dirserch::dirserch(char *ch){ n=0; path[0]=""; dir[0].push_back(0); dirname.push_back(ch); hd=NULL;} int dirserch::next(string &str){ for(;;){ if(hd==NULL){ int k=dir[n].size()-1; if(k<0){ if(n==0)return NULL; n--; continue; } path[n+1] = path[n] + dirname[dir[n][k]] + "\\"; dir[n].resize(k); n++; hd = FindFirstFile((path[n]+"*").c_str(), &fd);} for(;;){ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){ if(fd.cFileName[0]!='.' || ( fd.cFileName[1]!='.' && fd.cFileName[1]!='\0' )){ int k=dirname.size(); dir[n].push_back(k); dirname.push_back(fd.cFileName);}} else { str=path[n]+fd.cFileName; if(!FindNextFile(hd, &fd)){CloseHandle(hd); hd=NULL;} return 1;} if(!FindNextFile(hd, &fd)){CloseHandle(hd); hd=NULL;break;}}}} 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch