Author Topic: zTrace from dll  (Read 125 times)

James Fuller

  • Newbie
  • *
  • Posts: 20
zTrace from dll
« on: July 14, 2020, 12:12:59 pm »
Patrice,
  Can zTrace be used from a dll?
If so would you show an example?

Thank you and be safe,

James

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1771
    • zapsolution
Re: zTrace from dll
« Reply #1 on: July 14, 2020, 04:33:14 pm »
OF COURSE !!!

Code: [Select]
long zTrace(IN WCHAR* sPtr) {
    long nRet = 0;
    static HMODULE hDll;
    if (hDll == 0) {
        if (sizeof(LONG_PTR) == 8) {
            hDll = LoadLibrary(L"zTrace64");
        }
        else {
            hDll = LoadLibrary(L"zTrace32");
        }
    }
    if (hDll) {
        long_proc(WCHAR*);
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc)GetProcAddress(hDll, "zTrace"); }
        if (hProc) { nRet = hProc(sPtr); }
    }
    return nRet;
}
Patrice
(Always working with the latest Windows version available...)

James Fuller

  • Newbie
  • *
  • Posts: 20
Re: zTrace from dll
« Reply #2 on: July 14, 2020, 09:30:26 pm »
Thank you but...
missed a line:
#define long_proc typedef long (__stdcall *zProc)

I thought it might be different for a dll  but it is the same as the code I use for an exe.

James
 

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1771
    • zapsolution
Re: zTrace from dll
« Reply #3 on: July 14, 2020, 11:11:57 pm »
#define long_proc typedef long (__stdcall *zProc)

Yes, there is no difference.

The first purpose of zTrace was to help me to debug both WinLIFT.dll and GDImage.dll...
« Last Edit: July 14, 2020, 11:14:46 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

James Fuller

  • Newbie
  • *
  • Posts: 20
Re: zTrace from dll
« Reply #4 on: July 17, 2020, 11:42:28 am »
Patrice,
  It is the only debugging tool I use.
One issue I have is setting up the create debug.txt file from the dll I my trying to debug as there is no real place to stop the output so I can click on the zTrace window. Any suggestions?

James

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1771
    • zapsolution
Re: zTrace from dll
« Reply #5 on: July 17, 2020, 02:13:53 pm »
James

Sorry, i am unsure to understand what you mean by "there is no real place to stop the output so I can click on the zTrace window".

What you can do is to display a messagebox before full completion, to give you a chance to read the debug content.
Or you can use the zDebug option to create a zDebug.txt report.
« Last Edit: July 17, 2020, 02:15:36 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)