VC6中的DLL调试

152 篇文章 1 订阅
 

其实VC6中的DLL调试也不是太难的, 只是有时莫名其妙的不能进DLL里面的断点. 这里记录一下
1. 创建DLL工程
// TTTTDDD.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <windows.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

/
#ifdef __cplusplus
extern "C"{
#endif
 
 int __stdcall TestDll(int nA, int nB)
 {
  return nA + nB;
 }
 
#ifdef __cplusplus
}
#endif
/

extern "C" __declspec(dllexport) bool ForTest()
{
 ::MessageBoxA(0, "1", "2", MB_OK);
 return false;
}

-------------------------------------------------------------------------------
def文件内容

LIBRARY    "TTTTDDD"
EXPORTS
    TestDll @ 1
 
2. 在这个DLL工程上添加一个TestDLL工程(独立工程也可以)
// TestDLL.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#ifdef __cplusplus
extern "C"{
#endif
 
 int __stdcall TestDll(int nA, int nB);
 
#ifdef __cplusplus
}
#endif
extern "C" __declspec(dllexport) bool ForTest();

/

#pragma comment(lib, "../Debug/TTTTDDD.lib")  // 注意这里的路径

int main(int argc, char* argv[])
{
 int k = TestDll(4, 5);
 ForTest();      // 这里设断点, F11进入DLL代码
 return 0;
}

3. 没那么简单, 先看目录结构
***/TTTTDD/     // DLL工程目录
***/TTTTDD/Debug/   // DLL工程生成的Debug目录, TTTTDD.dll和TTTTDD.lib都在这里
***/TTTTDD/TestDLL/   // TestDLL工程目录
***/TTTTDD/TestDLL/Debug/ // 默认TestDLL.exe生成在这个目录
现在就要配置TestDLL的功过目录: TestDLL Project|Setting|Link|General|Output File Name 设置为../Debug/TestDLL.exe
也就是***/TTTTDD/Debug/TestDLL.exe.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值