C++ 獲取dll當前路徑下所有文件
更新時間:2023年09月01日 11:08:14 作者:^@^lemon tea^@^
本文主要介紹了C++ 獲取dll當前路徑下所有文件,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
在.cpp文件頭引用頭文件和作用域
using namespace std; #include <atlbase.h> #include<stdio.h> #include<string.h> #include<stdlib.h> #include <string> #include <fstream> #include<vector> #include<io.h> #include <direct.h> #include <iostream> #include <map>
獲取dll文件所在目錄地址和獲取文件信息
char filePath[MAX_PATH]; GetModuleFileNameA(_AtlBaseModule.GetModuleInstance(), filePath, MAX_PATH); std::string strDllPath(filePath); strDllPath = strDllPath.substr(0, strDllPath.find_last_of("\\") + 1); vector<string> files; getFilesAll(strDllPath, files); bool m_VerifyBytes[20] = { false };
功能代碼:獲取指定路徑下所有文件地址信息
void getFilesAll(string path, vector<string>& files) { //文件句柄 long hFile = 0; //文件信息 struct _finddata_t fileinfo; string p; if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1) { do { if ((fileinfo.attrib & _A_SUBDIR)) { if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) { getFilesAll(p.assign(path).append(fileinfo.name), files); } } else { files.push_back(p.assign(path).append(fileinfo.name)); } } while (_findnext(hFile, &fileinfo) == 0); _findclose(hFile); } }
到此這篇關于C++ 獲取dll當前路徑下所有文件的文章就介紹到這了,更多相關C++ 獲取dll所有文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關文章
C++ opencv ffmpeg圖片序列化實現(xiàn)代碼解析
這篇文章主要介紹了C++ opencv ffmpeg圖片序列化實現(xiàn)代碼解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-08-08c++ 虛函數(shù)與純虛函數(shù)的區(qū)別(深入分析)
本篇文章是對c++中虛函數(shù)與純虛函數(shù)的區(qū)別進行了詳細的分析介紹,需要的朋友參考下2013-05-05