Can a windows dll retrieve its own filename?
http://stackoverflow.com/questions/2043/can-a-windows-dll-retrieve-its-own-filename
A windows exe file has access to the command string which invoked it, including its path and filename. eg.
C:\MyApp\MyApp.exe --help.
But this is not so for a dll invoked via LoadLibrary. Does anyone know of a way for a dll to find out what its path and filename is?
Specifically I'm interested in a Delphi solution, but I suspect that the answer would be pretty much the same for any language.
I think you're looking for GetModuleFileName.
{
If you are working on a DLL and are interested in the filename of the
DLL rather than the filename of the application, then you can use this function:
}
function GetModuleName: string;
var
szFileName: array[..MAX_PATH] of Char;
begin
FillChar(szFileName, SizeOf(szFileName), #);
GetModuleFileName(hInstance, szFileName, MAX_PATH);
Result := szFileName;
end;
Getting the path of a DLL:
if you call ExtractFilePath(ParamStr(0)) from a DLL you will get the path of the web server, so if you want the path of the DLL itself use:
function ScriptPath: String;
var path: array[..MaxPathLength-] of char;
begin
if IsLibrary then
SetString(Result, path, GetModuleFileName(HInstance, path, SizeOf(path)))
else
Result := ParamStr();
end;
Can a windows dll retrieve its own filename?的更多相关文章
- C#实现动态调用Windows DLL
调用方法: object obj = WinDllInvoke("Kernel32.dll", "Beep", , }, typeof(void)); 函数代码 ...
- Windows Dll Injection、Process Injection、API Hook、DLL后门/恶意程序入侵技术
catalogue 1. 引言2. 使用注册表注入DLL3. 使用Windows挂钩来注入DLL4. 使用远程线程来注入DLL5. 使用木马DLL来注入DLL6. 把DLL作为调试器来注入7. 使用c ...
- go 调用windows dll 的方法
go 调用windows dll 的方法 ,代码如下: package main import ( "fmt" "syscall" "time&quo ...
- Creating Icon Overlay Handlers / 创建图标标记 Handlers (翻译自MSDN) / VC++, Windows, DLL, ATL, COM
创建图标标记 Handlers Creating Icon Overlay Handlers 图标标记是放在代表着某个 Shell 对象的图标之左下角的小图像.它们通常被加在一个对象的图标的身上来提供 ...
- Windows DLL资料整理
1.使用Visual C++ 6.0创建dll 2. 函数的调用规则(__cdecl,__stdcall,__fastcall,__pascal) 要点: 1. 如果你的程序中没有涉及可变参数,最好使 ...
- windows dll的def文件
DLL(testcase_1.dll )源码:myfun.h #pragma once #ifdef TESTCASE_1_EXPORTS #define MY_API __declspec(dlle ...
- go 调用windows dll 的三种方法
参考:https://blog.csdn.net/qq_39584315/article/details/81287669 大部分代码参考:https://studygolang.com/articl ...
- windows DLL中使用COM的注意事项
windows的DLL开发是有需要注意的地方的,不然会造成一些问题.由于我最近的使用不当,又造成了问题,虽然之前有写过一篇笔记, http://www.cnblogs.com/foohack/p/66 ...
- Creating Context Menu / 创建上下文菜单项 / VC++, Windows, DLL, ATL, COM
创建上下文菜单项 1.新建一个ATL Project. 2.建议将Project Property中Linker – General - “Register Output” 设为no,C/C++ - ...
随机推荐
- VC RichEdit中英文关键字标红
最近需要做vc的RichEdit控件里的内容关键字标红,由于RichEdit的内容可能是中英文混合的,所以需要先转成Unicode,再用wcsstr函数找到关键字出现的位置,再用SetSel.SelS ...
- linux---centos7 安装chromedriver
1.安装浏览器 指定yum 源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.re ...
- Effective STL 阅读笔记: Item 3: Make copying cheap and correct for objects in containers
容器 (Containers) 用来存储对象 (Objects), 但是被存储的对象却并非原原本本是你给他的那一个, 而是你指定对象的一个拷贝.而后续对该容器内存储对象的操作,大多也是基于拷贝的. 拷 ...
- javascript练习(二)
案例 输出100个数字 案例 打印100以内 7的倍数 案例 打印100以内的奇数 案例 打印100以内所有偶数的和 打印图形 ********** ********** ********** ...
- Adminimize 插件:WordPress根据用户角色显示/隐藏某些后台功能
倡萌刚才分享了 WordPress根据用户角色隐藏文章/页面的功能模块(Meta Boxes),如果你还想根据不同用户角色显示或隐藏后台的某些功能,比如 顶部工具条.左边导航菜单.小工具.仪表盘.菜单 ...
- 【重点】Jmeter----- 将 JDBC Request 查询结果作为下一个接口参数方法(二)
一.说明 jmeter与数据库mysql已连接成功 二.需求 1.前置条件: 1.已user数据库的前8位手机号码作为行动计划的名称 2.行动计划的日期是2018-10-17 2.操作步骤: 1)获取 ...
- win10家庭版和专业版远程桌面出现身份验证错误, 要求的函数不受支持。解决办法【亲测有效】
1.解决 win10家庭中文版 远程连接:出现身份验证错误 要求的函数不受支持 Windows 5.10日更新后,远程连接出现失败. 提示: 出现身份验证错误.要求的函数不受支持 这可能是由于 Cre ...
- 【LOJ】#2085. 「NOI2016」循环之美
题解 我们要求的其实是这个东西= = \(\sum_{i = 1}^{n}\sum_{j = 1}^{n}[(i,j) == 1][(j,k) == 1]\) 然后变一下形 \(\sum_{j = 1 ...
- bzoj 1113
思路:对于两张高度一样的海报 i, j, 即 y[ i ] = y[ j ], 如果对于任意i < k < j 有y[ k ] > y[ i ] && y[ k ] ...
- Mybatis源码分析之插件的原理
MyBatis 允许你在已映射语句执行过程中的某一点进行拦截调用. 默认情况下,可以使用插件来拦截的方法调用包括: Executor (update, query, flushStatements, ...