PowerBasic Museum 2020-A

IT-Consultant: Patrice Terrier => Discussion => Topic started by: Patrice Terrier on May 05, 2013, 08:21:56 PM

Title: zTrace converted to C/C++
Post by: Patrice Terrier on May 05, 2013, 08:21:56 PM
Topic moved here (http://www.jose.it-berater.org/smfforum/index.php?topic=4688.msg18228;topicseen#msg18228)
Title: Re: zTrace converted to C/C++
Post by: Patrice Terrier on May 06, 2013, 11:10:29 AM
I did a small change to the thread creation source code and i added two missing {} in the WM_COMMAND, to let it work.

Now the zTrace.dll 64-bit is alive, at least by me  ;D

that would help me to further debug my 64-bit DLL(s)...
Title: Re: zTrace converted to C/C++
Post by: James C. Fuller on May 06, 2013, 01:30:48 PM
Patrice,
  I was able to compile in both 32 and 64 bit with the cl from the 7.1 SDK.
I get the zTrace window when testing but the text is gibberish.
Can you show just a simple demo of it's use?

James
Title: Re: zTrace converted to C/C++
Post by: Patrice Terrier on May 06, 2013, 02:03:51 PM
James--

it is using UNICODE !!!

I shall post very soon the compiled version for 32/64 bit (both working in Unicode)
The original PowerBASIC version works in ANSI.
Title: Re: zTrace converted to C/C++
Post by: James C. Fuller on May 06, 2013, 02:15:43 PM
I know it's unicode and I did figure out you need to pass a WCHAR string but I wanted to see a c++ snippet of calling it from you.

BTW I compiled both 32 and 64 bit dll's without name mangling so I can easily call zTrace from any language.

Good work.

James


Title: Re: zTrace converted to C/C++
Post by: James C. Fuller on May 06, 2013, 02:28:26 PM
Ok I got it.
It was in the declare so I could pass a wstring -> ws.c_str()
I needed const and you should probably add it to the function also.
James


typedef LONG_PTR (__cdecl *BCXFPROT1)(const WCHAR*);

static BCXFPROT1 zTrace;

int WINAPI WinMain (HINSTANCE  hInst,HINSTANCE  hPrev,LPSTR  CmdLine,int CmdShow)
{

// **********[ DLL Declarations ]**********

HMODULE  H_ZTRACE64 = LoadLibrary("ztrace64.dll");
zTrace=(BCXFPROT1)GetProcAddress(H_ZTRACE64, "zTrace");

// ****************************************

  wstring  ws;
  LONG_PTR  rv;
  ws= L"James";
  rv= zTrace( ws.c_str());
  MessageBox (GetActiveWindow(),(join(2,"rv = ",str(rv))),"",0);
}
Title: Re: zTrace converted to C/C++
Post by: James C. Fuller on May 06, 2013, 02:50:58 PM
Patrice,
I only tested the zTrace function but the dll's I created work with:

MinGW gcc 32/64
MinGw g++ 32/64
VC++(wiin 7.1 sdk) 32/64
Borland c++ 5.5 32
PellesC 7R   32/64
Tiny c 32

James