Quantcast
Channel: SCN : All Content - PowerBuilder Developer Center
Viewing all articles
Browse latest Browse all 2935

Please update PB Documentation regarding WIN32 System Calls for x86/x64

$
0
0

Hi There,
i fighting with around  1200 System Calls kernel32.dll, user32.dll, shell32.dll own C code  which are called from PB 12.5 under 32Bit which should work in the 64Bit's World of PB15.


What i missing is a good PB documentation to call the win32 API. There is a rather old one “EXTERNAL FUNCTION CALLS” (http://www.sybase.com/detail?id=44474) from October 1997 which seems to be copied over the time into different PB versions and which seems to be only moderate updateded in the PB Documentation / Online Books.


Additionally I found a few “Hints” (Code Examples) from the old PB Guru like Bruce Armstong , Chris Pollach or Roland Smith (TopWiz) and others – Thanks for sharing your knowledge!


But I would like to have a better documentation how and what to do and not tying around with datatypes not realy knowing what im doing and hoping to preserve the memory structure.

One example is the use of SendMessage to update the Statusbar (msctls_statusbar32)

 

Declaration:
Function boolean SendMessage(ulong hWnd, ulong Msg, ulong wParam, Ref string szText ) Library "user32.dll" alias for "SendMessageA;Ansi"

That worked until PB12.5 (;ansi convert UNICODE szText into ANSI szText)

 

CALL as_text is String

lb_result = SendMessageString(Handle(This),  SB_SETTEXT,  lptr_part - 1,as_text) // ANSI SendMessageA


In PB 15 I only see the first character of each String in the StatusBar.

 

So I would expect that I have to Change to:


Function boolean SendMessageW(LongPtr hWnd, ULong Msg,  LongPtr wParam,  Ref String szText ) Library "user32.dll”

//(SendMessage should map automatically to SendMessageW in UNICODE )

CALL as_text is String, lptr_part is longPtr

lb_result = SendMessageStringW(Handle(This),  SB_SETTEXT,  lptr_part - 1, as_text) // UNICODE SendMessageW

But that did not work in PB 15, what I figure out is that I Can use in a 32Bit Project is:
Function boolean SendMessageStringA(LongPtr hWnd, ULong Msg,  LongPtr wParam,  Ref blob szText ) Library "user32.dll" alias for "SendMessageA"


lb_blob = Blob(as_text, EncodingANSI!)
lb_result = SendMessageStringA(Handle(This),  SB_SETTEXT,  lptr_part - 1, lb_blob) // ANSI SendMessageA
But that did not work with a 64Bit…


Today we calculate the Bits for Structures manually on 32Bit Size for dwOSVersionInfoSize
typedef struct _OSVERSIONINFOEX {
  DWORD dwOSVersionInfoSize;
  DWORD dwMajorVersion;
  DWORD dwMinorVersion;
  DWORD dwBuildNumber;
  DWORD dwPlatformId;
  TCHAR szCSDVersion[128];
  WORD  wServicePackMajor;
  WORD  wServicePackMinor;
  WORD  wSuiteMask;
  BYTE  wProductType;
  BYTE  wReserved;
} OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX;

 

Nice would be a “SizeOf” operator we have in the C/C++ world, so we did not have to worry about if TCHAR szCSDVersion is in C++ Multibyte/Unicode or not depending if  _UNICODE is defined or not.


#ifdef _UNICODE
typedef wchar_t TCHAR;
#else
typedef char TCHAR;
#endif

 

(I know1200 is too much and shows a bad encapsulation but the codebase is 20 years old, maintained from the third company now, and as so often there was no time for refactoring.
The boss as why spending time when its all running...  )


So please update the Documentation and Compiler checkings ...

 

Regards

   Marco


Viewing all articles
Browse latest Browse all 2935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>