词条 | EnumResourceTypes |
释义 | API说明函数功能:该函数为资源搜寻模块并且将它找到的每个资源类型传递给用户定义的回调函数。 函数原型:BOOL EnumResourceTypes(HMODULE hModule,ENUMRESTYPEPROC lpEnumFunc,LONG IParam); 参数: hModule:处理包含被列举资源类型的可执行文件的模块。如果这个参数为NULL,那么函数将在模块中列举出创建当前过程的资源类型。 lpEnumFunc:指向所需要每个列举出的资源类型的响应函数。如要了解更多的信息请参见 EhumResNameProc。 IParam:指定申请定义值传递给响应函数。 返回值:若函数运行成功,则返回非零值;若函数运行失败,则返回零值。若想获得更多的错误信息,请调用GetLastError函数。 注意:函数将连续列举出资源名称,直到响应函数返回False值或全部的资源名称均被列举完毕。 速查:Windows NT 3.1、Windows 95以上,头文件:winbase.h;库文件:kernel32.lib;Unicode:在Windows和Windows NT上实现为Unicode和ANSI两种版本。 AAuto范例 枚举DLL中的资源类型//导入文件操作函数库 import fsys; //加载DLL dll = raw.loadDll(fsys.getExeDir()+"lib\\labs\\au3\\.dll") hModule = dll.gethandle() //这样可以得到模块句柄 //声明枚举资源类型API EnumResourceTypes= ::Kernel32.api("EnumResourceTypes","int( pointer hModule,pointer lpEnumFunc,int lParam)"); //回调函数 EnumResTypeProc=function(hModue,lpszType,lParam){ //该类型是一个字符串吗? if( lpszType >>> 16 /* not IS_INTRESOURCE*/) { //Otherwise, it is a pointer to a null-terminated string //是字符串 //将数值用topointer转换为指针,再用raw.tostring转换为字符串 lpszType = raw.tostring(topointer(lpszType) ) //如果他的第一个字节码是#号 if(lpszType[1]=='#'#){//If the first character of the string is a pound sign (# //那面后面是一个数值 lpszType = tonumber( //then the remaining characters represent a decimal number that specifies the integer identifier of the resource type string.sub(lpszType,2) //For example, the string "#258" represents the identifier 258. ) } } else{ //IS_INTRESOURCE(lpszType) is TRUE, then lpszType specifies the integer identifier of the given resource type //否则是int } io.print(lpszType); return 1; } //将AAuto函数转换为回调函数指针 pEnumwndProc = raw.tostdcall(EnumResTypeProc,"int(pointer hModule,int lpszType,int lParam)"); //打开控制台 io.open() //列出资源类型 EnumResourceTypes(hModule,pEnumwndProc,0) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。