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++ - ...
随机推荐
- LightOJ 1369 Answering Queries(找规律)
题目链接:https://vjudge.net/contest/28079#problem/P 题目大意:给你数组A[]以及如下所示的函数f: long long f( int A[], int n ...
- Funny Car Racing(最短路变形)
描述 There is a funny car racing in a city with n junctions and m directed roads. The funny part is: e ...
- cocos2d-x v2.2 IOS工程支持64-bit 遇坑记录
修改缘由 由于 iPhone 5S的A7 CPU iPhone 6(A8 CPU)都已经支持64-bit ARM 架构,据说64位处理器跑64代码会提高处理能力?因此二月一新提交appstore应 ...
- 关于js函数 形参和局部变量名相同 的问题
原文:https://segmentfault.com/q/1010000007278354?_ea=1295176 问题: function f1(a) { console.log(a);// 10 ...
- 想弄一弄tensorflow,先弄numpy
现在晚上凉快点了, 下班回家可以学会东东了.. 这次的书是一个印度人写的. 按着示例代码弄起先.. #!/usr/bin/env python # -*- coding: utf-8 -*- impo ...
- spring-cloud-sleuth+zipkin追踪服务实现(一)
1.简述 最近在学习spring cloud构建微服务,研究追踪微服务rest服务调用链路的问题,接触到zipkin,而spring cloud也提供了spring-cloud-sleuth来方便集成 ...
- js学习笔记1:语法、数据类型与转换、运算符与运算
注意: 上部代码错误,将停止运行,下部的代码无法显示 typeof 用来定义内容类型,不会输出内容只会输出类型 一.js输出语法 1. 弹窗输出('')内的内容: ...
- C# asp.net 实现导出Excel
原文地址:传送门 这段时间用到了导出Excel的功能,这个功能还是比较常用的,我常用的有两个方法,现在整理一下,方便以后查看. 1.实现DataTable数据导出到本地,需要自己传进去导出的路径. / ...
- cordova 整合 webpack vue
cordova 是hybrid开发app的一个框架,通过js桥接原生api实现了js调用原生的一些功能:本打算学习下阿里的weex:可是一直打包不了,加上之前也用过cordova,打算使用cordov ...
- thinkjs REST API的跨域设置
用thinkjs也有一小段时间了,和其它国产框架一样,起初是处于观望态度.当然我最先的选择也不是thinkjs而是选的express,用到后面发现实现一个能让自己用着比较顺手的博客还是一件蛮困难或者说 ...