windows api一日一练(dbghelp sdk)-002-MakeSureDirectoryPathExists,SearchTreeForFile
2009-10-15 13:54
916 查看
分类:General
函数:
MakeSureDirectoryPathExists: 创建目录,可一次创建多层目录结构,很方便的函数
SearchTreeForFile:搜索文件并返回路径
――――――――下面是代码和注释――――――――――――――――――――
MakeSureDirectoryPathExists("E://dbghelp_study//DbgHelpFunctions//debug3//");
注意参数最后要有’/’,成功返回t
SearchTreeForFile("e://","DbgHelpFunctions.sln",szBuf);
找到就返回t,并且路径被填充进buf,否则返回是f
上面的函数还可以注册回调,回调的样子是这样的:
BOOL CALLBACK MySymRegisterCallbackProc64( // 函数名随意换
HANDLE hProcess,// 4个参数都是系统传进来的
ULONG ActionCode,// 这个是CBA_DEFERRED_SYMBOL_LOAD_CANCEL=0x00000007
ULONG64 CallbackData,// 这个是0,无用
ULONG64 UserContext) // 这个是在外面注册回调时候设置的上下文
{
// LPAPI_VERSION p = (LPAPI_VERSION)UserContext;
return FALSE;
}
是使用这个函数注册:
SymRegisterCallback64(hProcess,MySymRegisterCallbackProc64,(ULONG64)pVer);
Pver是个上下文参数,类型可以随意,但要转为ulong,这样在回调函数在被调用的时候上下文就能被传进到MySymRegisterCallbackProc64里了。
注册回调要在SearchTreeForFile执行之前,这样在搜索的时候,系统会每个文件夹都回调一次定义的函数,方便在搜索时由于时间可能很长造成的延迟。比如可以写一些代码当搜索n个文件夹之后cancel掉。
回调中的返回值是f时候则搜索函数继续搜,为t就stop了
我在想如果要收集一个path下的多个子目录中同一个名字的文件,这个函数能不能用上呢?
函数:
MakeSureDirectoryPathExists: 创建目录,可一次创建多层目录结构,很方便的函数
SearchTreeForFile:搜索文件并返回路径
――――――――下面是代码和注释――――――――――――――――――――
MakeSureDirectoryPathExists("E://dbghelp_study//DbgHelpFunctions//debug3//");
注意参数最后要有’/’,成功返回t
SearchTreeForFile("e://","DbgHelpFunctions.sln",szBuf);
找到就返回t,并且路径被填充进buf,否则返回是f
上面的函数还可以注册回调,回调的样子是这样的:
BOOL CALLBACK MySymRegisterCallbackProc64( // 函数名随意换
HANDLE hProcess,// 4个参数都是系统传进来的
ULONG ActionCode,// 这个是CBA_DEFERRED_SYMBOL_LOAD_CANCEL=0x00000007
ULONG64 CallbackData,// 这个是0,无用
ULONG64 UserContext) // 这个是在外面注册回调时候设置的上下文
{
// LPAPI_VERSION p = (LPAPI_VERSION)UserContext;
return FALSE;
}
是使用这个函数注册:
SymRegisterCallback64(hProcess,MySymRegisterCallbackProc64,(ULONG64)pVer);
Pver是个上下文参数,类型可以随意,但要转为ulong,这样在回调函数在被调用的时候上下文就能被传进到MySymRegisterCallbackProc64里了。
注册回调要在SearchTreeForFile执行之前,这样在搜索的时候,系统会每个文件夹都回调一次定义的函数,方便在搜索时由于时间可能很长造成的延迟。比如可以写一些代码当搜索n个文件夹之后cancel掉。
回调中的返回值是f时候则搜索函数继续搜,为t就stop了
我在想如果要收集一个path下的多个子目录中同一个名字的文件,这个函数能不能用上呢?
相关文章推荐
- VC++ MFC 创建多级目录的方法 MakeSureDirectoryPathExists (另附 文件、目录操作类)
- MakeSureDirectoryPathExists和CreateDirectory的区别
- MakeSureDirectoryPathExists检查目录是否存在
- MakeSureDirectoryPathExists与CreateDirectory的区别
- MakeSureDirectoryPathExists参数不能是正斜杠(“/”)
- MakeSureDirectoryPathExists与CreateDirectory的区别
- 2014-03-14周五工作日志:检查指定目录是否存在的函数MakeSureDirectoryPathExists
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- MakeSureDirectoryPathExists
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- 使用MakeSureDirectoryPathExists 创建多级目录
- 使用 MakeSureDirectoryPathExists 迅速建立多级目录
- linux下安装vmware Could not open /dev/vmmon: No such file or directory. Please make sure that the kerne
- mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
- Unable to list target platforms. Please make sure the android sdk path is correct. See the Console for more details.
- Starting MySQL:mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
- ubuntu vmware xp Could not open /dev/vmmon: No such file or directory. Please make sure that the ke
- 解决mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists
- Starting MySQL ** mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists
- QT:make: Nothing to be done for `first'和error:QtSql:No such file or directory