- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在写这样一个 dllmain:
#include "main.h"
#include "init.h"
#include <iostream>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
//std::cout<<"hi\n"; //only for debug. did not shown.
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
//std::cout<<"hello\n"; //only for debug. did not shown.
init(); //did not run :(
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
但是在一个测试程序使用LoadLibrary()之后,没有任何反应,屏幕上没有你好或嗨。你想弄清楚这个问题吗?非常感谢!
附言我看过问题DllMain not being called但它仍然无济于事。
PS2:调用程序是这样的
int main()
{
cout<<"This is a test program to test.\n";
HINSTANCE hinstDLL;
hinstDLL=LoadLibrary("ijl15.dll");
cout<<"Look like everything goes well.\n";
cout<<hinstDLL;
return 0;
}
测试程序输出:
This is a test program to test.
Look like everything goes well.
0x6a980000
Process returned 0 (0x0) execution time : 0.007 s
Press any key to continue.
最佳答案
经过一些尝试(很多 :( ) 我发现我错过了
#define DLL_EXPORT extern "C" __declspec(dllexport)
这使得函数名正确,最终成功调用了DLLMain。总之谢谢大家!
关于c++ - Dllmain 没有被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6161844/
我正在学习 DLL,我在 MSDN 中看到了以下段落: If you are providing your own entry-point, see the DllMain function. The
我正在写这样一个 dllmain: #include "main.h" #include "init.h" #include BOOL WINAPI DllMain(HINSTANCE hinstD
行情: 来自文档“创建 DLL 的最佳实践”http://download.microsoft.com/download/a/f/7/af7777e5-7dcd-4800-8a0a-b18336565
似乎当在 DLL_PROCESS_ATTACH 上从 DllMain 中创建线程时,只有在加载所有 dll 后,该线程才会开始。由于我需要确保线程在继续之前运行,因此出现了死锁。有没有办法强制线程启动
我正在编写一个定义全局静态对象的 DLL。 在对象的构造函数中,我正在执行一些可能成功也可能不成功的初始化。 是否可以在 DllMain() 中发出初始化过程成功或失败的信号?这两个中哪一个先被调用?
我正在为某个系统编写一个插件,但是有一些行为不端的应用程序在 dll 初始化期间调用了我的插件(来自 DllMain 或 InitInstance,它是 DllMain 的包装器)。 我想知道是否有办
这个问题在这里已经有了答案: Creating a thread in DllMain? (4 个答案) 关闭 7 年前。 这可能是显而易见的事情,但对我来说意义不大。我正在尝试创建一个 dll,它
我正在编写一个非托管 dll(使用 C++ 和 WinAPI),但我想使用一些 C# 方法,因此,我使用 C++/CLI 创建了一个包装器。 但问题是:非托管 dll 将被“注入(inject)”(L
我有一个 C++ 程序,它有一个 DLLMain 函数,当这个程序(实际上是一个 DLL)被另一个程序加载时,该函数运行一些代码。这工作正常。 现在,当我这次编译同一个 C++ 程序时,包括一个已经定
我正在尝试创建 DLL 文件,但在 DLLMAIN() 中运行函数时遇到问题。 我想做这样的事情: #include "stdafx.h" #include #include INT APIENT
我尝试在 Borland c++ 5.02 中创建 *.dll 文件,我对这个函数有疑问 BOOL APIENTRY DllMain( HANDLE hModule,
我有一个 Dllmain,它在线程附加到此 DLL 时分配线程本地存储。代码如下: BOOL APIENTRY DllMain(HMODULE hModule,
知名度之一DLLMain函数参数是 LPVOID lpvReserved。来自 MSDN 文档: If fdwReason is DLL_PROCESS_ATTACH, lpvReserved is
我想编写 DLL,但我想测试我正在编写的内容。 我尝试用 F5 调试它,但我收到一个错误: 我读了文章Walkthrough: Creating and Using a Dynamic Link Li
哪些函数在 DllMain() 之前被调用?如果在 C 运行时初始化期间不止一个,那么顺序很重要。 最佳答案 来自source :- If your DLL is linked with the C
在 *nix .so 库中,是否存在在加载和卸载库时由系统调用的入口点? 更实用的一点是:如果 .so 是用 C++ 编写的,并且它包含带有构造函数和析构函数的全局对象,并且它是从没有构造/析构概念的
我在多个来源中了解到,CreateProcess 不得从 DllMain 函数中调用。 CreateProcess : 不要从 DllMain 函数调用 CreateProcess。这会导致应用程序停
我在多个来源中了解到,CreateProcess 不得从 DllMain 函数中调用。 CreateProcess : 不要从 DllMain 函数调用 CreateProcess。这会导致应用程序停
当设置了线程特定的 Hook 时,DLL 中的原因代码是什么? 谁能帮我解决这个问题吗? 谢谢,阿什什。 最佳答案 您的问题仍然不清楚,但我假设您的意思是使用 SetWindowsHookEx() 安
我想创建一个 dll,在某些情况下自行卸载,这意味着 BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID
我是一名优秀的程序员,十分优秀!