Powerbasic Museum 2020-B

Archive => Archived Posts => Topic started by: Dominic Mitchell on March 29, 2011, 10:02:40 PM

Title: PBWin10 and COM
Post by: Dominic Mitchell on March 29, 2011, 10:02:40 PM
Finding out what is different between 9 and 10 should be interesting.
My Component Object Model SDK class successfully compiles on both version 9 and 10, but
the exe produced by version 10 GPF's.
Title: Re: PBWin10 and COM
Post by: José Roca on March 29, 2011, 10:11:30 PM
Regarding COM, the major change is native Unicode support.

Also, if you use internal callback classes that are called by an external application, you must declare them as COMMON to avoid code removal.
Title: Re: PBWin10 and COM
Post by: José Roca on March 29, 2011, 10:30:26 PM
 
Another change is that VARIANT$ is now for VARIANTs containing an ANSI string. For VARIANTs containing an Unicode string you must use VARIANT$$.
Title: Re: PBWin10 and COM
Post by: Dominic Mitchell on March 29, 2011, 10:45:51 PM
#OPTIMIZE CODE OFF does not solve the problem.

I will check Unicode/Variant$ later.
Title: Re: PBWin10 and COM
Post by: Eros Olmi on March 29, 2011, 11:02:02 PM
Maybe

#OPTION ANSIAPI
Title: Re: PBWin10 and COM
Post by: José Roca on March 29, 2011, 11:25:52 PM
Quote
I will check Unicode/Variant$ later.

Got it working just changing three VARIANT$ to VARIANT$$ in SDK_Class.bas.
Title: Re: PBWin10 and COM
Post by: Dominic Mitchell on March 29, 2011, 11:42:58 PM
Thanks.
The utility I use to track down GPFs does not handle PowerBASIC COM syntax. I was in the process of modifying it.
If PB 10 handles calculated references, I will just specify that the SDK class must be used with
version 10 or higher of the compiler.
On second thought, I will not bother supporting version 9 for this class.
Title: Re: PBWin10 and COM
Post by: José Roca on March 30, 2011, 12:02:29 AM
Quote
If PB 10 handles calculated references [...]

Unfortunately, it does not.

The two features I was most interested and that I have checked thoroughly during the beta testing, are unicode support and dead code removal.

No more need for ACODE$/UCODE$ and USEMACROS, and no more need for workarounds such declaring a null terminated string parameter as DWORD, using an ansi string with UCODE$ and passing it with STRPTR. Now, these parameters are declared as BYREF WSTRINGZ.

Dead code removal is allowing me to write classes and tons of wrapper functions that don't add bloat. It's a great way of extending the language.

Your ListView example for the SDK_Class compiled to 199 KB using PB9 and now compiles to 97 KB using PB 10 and my new headers.


Title: Re: PBWin10 and COM
Post by: Dominic Mitchell on March 30, 2011, 12:15:08 AM
Thanks again, you just saved me a lot of trouble.

The size reduction is very impressive.  It means I can add functionality to the class with total abandon.
Title: Re: PBWin10 and COM
Post by: Jean-Pierre Leroy on March 30, 2011, 12:16:24 PM
QuoteNo more need for ACODE$/UCODE$ and USEMACROS, and no more need for workarounds such declaring a null terminated string parameter as DWORD, using an ansi string with UCODE$ and passing it with STRPTR. Now, these parameters are declared as BYREF WSTRINGZ.

Hi José,

Some times ago you wrote some codes to retrieve the date and time when the original image data was generated; it was in this thread (http://www.powerbasic.com/support/pbforums/showthread.php?t=43429)

Following your advices, I adapted the code with the new WSTRINGZ string data type and everything works fine now; thanks.

With PB9

Local lPictureFileName As String   
lPictureFileName = UCode$(pPictureFileName)
hStatus = GdipLoadImageFromFile(StrPtr(lPictureFileName), pImage)


With PB10

Local lPictureFileName As WSTRINGZ*%MAX_PATH 
lPictureFileName = pPictureFileName
hStatus = GdipLoadImageFromFile(lPictureFileName, pImage)


Thanks,
Jean-Pierre