请问这两个函数是干什么用的,大体是什么功能,那里有具体一点的介绍,在msdn上看了半天还是没有明白是什么意思,在此小弟先谢了,我重新写了一个小个程序,就出现下列情况,
testsym.obj : error LNK2001: unresolved external symbol __imp__SymInitialize@12
Debug/testsym.exe : fatal error LNK1120: 1 unresolved externals
是怎么回事呀!谢谢!

解决方案 »

  1.   

    #pragma comment(lib, " Dbghelp.lib")
      

  2.   

    Header: Declared in Dbghelp.h.
    Library: Use Dbghelp.lib.
    # include <Dbghelp.h>
    #pragma comment(lib, "Dbghelp.lib")
      

  3.   

    http://www.microsoft.com/china/MSDN/library/windev/COMponentdev/ACOMSymbolEngineAidsDebugging.mspx
    MS的中文介绍,还有相关例子
      

  4.   

    对了例子编译的时候会有
    Error Message: C2668: InlineIsEqualGUID: Ambiguous Call to Overloaded Function
    这个编译错误,把每个InlineIsEqualGUID改为::ATL::InlineIsEqualGUID() ,这是因为SDK和alt空间的名字空间问题。
      

  5.   

    谢谢上面的高人,但是问题还没有完全解决。能在指点指点吗?
    我写了一个简单的程序,
    main(int argc,char *argv[] )
    {
    int err;
    HANDLE dhandle; printf("this is test\n");
    printf("argv[0]:%s,argv[1]:%s\n",argv[0],argv[1]); //dhandle = GetCurrentProcess();
    //SymInitialize(dhandle,"",FALSE);

    if(!SymInitialize(GetCurrentProcess(),"",FALSE))
    {
    err=GetLastError();
    printf("Failed Initailize Process Symbol table,WIN32 Errcd:%d",err);
    return 0;
    }
    if(!SymLoadModule(GetCurrentProcess(),NULL,argv[0],NULL,0,0))
    {
    err=GetLastError();
    printf("Failed load symbol filename:%s,WIN32 Errcd:%d",argv[0],err);
    return 0;

    }dbghelp.lib是在vc的开发环境中设置的,现在问题出现了,我在vc的开发环境下运行没有问题,但是我直接在console下,键入命令就出现问题了
    C:\vctest\testmain\Debug>testmain
    this is test
    argv[0]:testmain,argv[1]:(null)
    Failed load symbol filename:testmain,WIN32 Errcd:0
    或者
    C:\vctest\testmain\Debug>C:\vctest\testmain\Debug\testmain
    this is test
    argv[0]:C:\vctest\testmain\Debug\testmain,argv[1]:(null)
    Failed load symbol filename:C:\vctest\testmain\Debug\testmain,WIN32 Errcd:0
    再次感谢
      

  6.   

    而且不能加# include <Dbghelp.h>
    如果加了dbghelp.h的话,将会出现大量的错误!
    我用的是#include <Imagehlp.h>
    请问#include <Imagehlp.h>和dbghelp.h有区别吗?我是指就运行SymInitialize()和SymLoadModule()这两个函数而言,谢谢
      

  7.   

    这两个函数的使用,MSDN0209期的buglayers中有详细的从事贸易子。
      

  8.   

    #pragma comment (lib,"imagehlp.lib"),
      

  9.   

    SymInitialize
    The SymInitialize function initializes the symbol handler for a process.BOOL SymInitialize(
      IN HANDLE hProcess,     
      IN LPSTR UserSearchPath,  
      IN BOOL fInvadeProcess  
    );
     
    Parameters
    hProcess 
    Handle to the process for which symbols are to be maintained. If the application is a debugger, use the process handle for the object being debugged, otherwise use the GetCurrentProcess function to obtain the process handle. 
    UserSearchPath 
    Pointer to a null-terminated string that specifies a path, or series of paths separated by a semicolon (;), that is used to search for symbol files. If a value of NULL is used, then ImageHlp attempts to form a symbol path from the following sources: 
    Current directory 
    Environment variable _NT_SYMBOL_PATH 
    Environment variable _NT_ALTERNATE_SYMBOL_PATH 
    Environment variable SYSTEMROOT 
    fInvadeProcess 
    If this value is TRUE, ImageHlp enumerates the loaded modules for the process and effectively calls the SymLoadModule function for each module. 
    Return Values
    If the function succeeds, the return value is TRUE.If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.Res
    The SymInitialize function is used to initialize the symbol handler for a process. In the context of the symbol handler, a process is a convenient object to use when collecting symbol information. Usually, symbol handlers are used by debuggers and other tools that need to load symbols for a process being debugged. ///////////////////////////////////////////////
    SymLoadModule
    The SymLoadModule function loads the symbol table. BOOL SymLoadModule(
      IN HANDLE hProcess,  
      IN HANDLE hFile,     
      IN LPSTR ImageName,  
      IN LPSTR ModuleName, 
      IN DWORD BaseOfDll,  
      IN DWORD SizeOfDll   
    );
     
    Parameters
    hProcess 
    Handle to the process that was originally passed to the SymInitialize function. 
    hFile 
    Handle to the file for the executable image. This argument is used mostly by debuggers, where the debugger passes the file handle obtained from a debug event. A value of NULL indicates that hFile is not used. 
    ImageName 
    Pointer to a null-terminated string that specifies the name of the executable image. This name can contain a partial path, a full path, or no path at all. If the file cannot be located by the name provided, the symbol search path is used. 
    ModuleName 
    Pointer to a null-terminated string that specifies a shortcut name for the module. If the pointer value is NULL, ImageHlp creates a name using the base name of the symbol file. 
    BaseOfDll 
    Specifies the load address of the module. If the value is zero, ImageHlp obtains the load address from the symbol file. The load address contained in the symbol file is not necessarily the actual load address. Debuggers and other applications having an actual load address should use the real load address when calling this function. 
    SizeOfDll 
    Specifies the size of the module. If the value is zero, ImageHlp obtains the size from the symbol file. The size contained in the symbol file is not necessarily the actual size. Debuggers and other applications having an actual size should use the real size when calling this function. 
    Return Values
    If the function succeeds, the return value is TRUE.If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.Res
    The symbol handler creates an entry for the module and if the deferred symbol loading option is turned off, an attempt is made to load the symbols. If deferred symbol loading is enabled, the module is ed as deferred and the symbols are not loaded until a reference is made to a symbol in the module.To unload the symbol table, use the SymUnloadModule function. 
      

  10.   

    DentistryDoctor,牙科医生兄你说的MSDN0209期的buglayers中有详细的从事贸易子,在那里能找到相关的资料,小弟先谢了!