VS2005中调试DLL库

    技术2022-05-19  23

    VS2005中调试DLL库DLL库是VS2005中编译得到的;

    一、找到调用该DLL库的EXE文件所在路径

    例如,EXE文件是VC6.0工程的可执行文件。

    找到project--》settings,选择Debug选项卡,Executable for debug session中的路径即为可执行文件路径,

    复制该路径

    二、打开VS2005中的DLL工程

    右击工程名--》properties-》configuration properties-》Debugging

    在command中,输入一中的路径(包括EXE文件名);

    在command中输入EXE文件名,在working directory中输入路径;

    三、F5调试

    其他调试步骤跟普通工程的调试方法相同。

     

    vs2005中获取文件路径的一种方法:

    首先声明存储路径的字符数组,建议使用TCHAR类型,便于不同字符集类型的兼容。然后调用全局函数GetModuleFileName(),获取得到的是包含可执行文件名的路径,可以根据需要对字符串进行操作及类型转换。

    TCHAR exePathAndName[MAX_PATH];

     GetModuleFileName(NULL, exePathAndName, MAX_PATH);

     (_tcsrchr(exePathAndName,'//'))[1]=0; //去掉可执行文件名,(_tcsrchr(exePathAndName,'//')指向了“//”的字符地址。

    ///将TCHAR类型转换成string类型 USES_CONVERSION; string filepath = T2A(exePathAndName);

     

    代码如下:

    //#include <windows.h>#include <string>#include <AtlBase.h>#include <AtlConv.h>#include <iostream>

    using namespace std;void main(void){ TCHAR exePathAndName[MAX_PATH];

     GetModuleFileName(NULL, exePathAndName, MAX_PATH); USES_CONVERSION; string filepath = T2A(exePathAndName); cout << filepath <<endl;

     (_tcsrchr(exePathAndName,'//'))[1]=0; //去掉可执行文件名,(_tcsrchr(exePathAndName,'//')指向了“//”的字符地址。

     ///将TCHAR类型转换成string类型

     filepath = T2A(exePathAndName); cout << filepath <<endl;}


    最新回复(0)