Alaska Software Inc. - Vttype() and VT_CLSID
Username: Password:
AuthorTopic: Vttype() and VT_CLSID
Lorenzo SucciVttype() and VT_CLSID
on Wed, 31 Jan 2024 15:28:29 +0100
Hello,
I'm trying without success to build a VT_CLSID type for an ActiveX 
function (WIA scanner, set output to JPEG format)
I try in Xbase (version 2.00.1440):

/////////////////////////
#include "activex.ch"
cls

   ORIGINAL := "B96B3CAE-0728-11D3-9D7B-0000F81EF32E"
//ORIGINAL := "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
//ORIGINAL := uuidfromchar("B96B3CAE-0728-11D3-9D7B-0000F81EF32E")
//ORIGINAL := {B96B3CAE-0728-11D3-9D7B-0000F81EF32E}    syntax error
//ORIGINAL := {"B96B3CAE-0728-11D3-9D7B-0000F81EF32E"}

//X:=automationbinarystring(ORIGINAL)    VT_VTARRAY | VT_UI1  wrong value

CONVERT:=vttype():new(ORIGINAL,VT_CLSID)     parameter has a wrong value

//CONVERT:=vttype():new(@ORIGINAL,VT_CLSID)     parameter has a wrong 
value

return
/////////////////////////

All tests has a result "parameter has a wrong value"
Someone have an idea?
Andreas Gehrs-Pahl
Re: Vttype() and VT_CLSID
on Wed, 31 Jan 2024 21:50:04 -0500
Lorenzo,

VT_CLSID is a pointer to a 16 byte GUID value. So try this:

VT_CLSID := UuidFromChar("B96B3CAE-0728-11D3-9D7B-0000F81EF32E")

Then pass the VT_CLSID by reference, using: @VT_CLSID.

Hope that helps.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Lorenzo SucciRe: Vttype() and VT_CLSID
on Thu, 01 Feb 2024 07:59:40 +0100
Il 01/02/2024 03:50, Andreas Gehrs-Pahl ha scritto:
> Lorenzo,
> 
> VT_CLSID is a pointer to a 16 byte GUID value. So try this:
> 
> VT_CLSID := UuidFromChar("B96B3CAE-0728-11D3-9D7B-0000F81EF32E")
> 
> Then pass the VT_CLSID by reference, using: @VT_CLSID.
> 
> Hope that helps.
> 
> Andreas

Good observation,
I missed that is a "pointer to", so i tested:

ORIGINAL:="B96B3CAE-0728-11D3-9D7B-0000F81EF32E"
CONVERT1:=uuidfromchar(ORIGINAL)
CONVERT2:=vttype():new(@CONVERT1,VT_CLSID)

but remain the error "wrong value in VTTYPE:INIT"

I also tried to merge the VT types:
 #define VT_CLSID                                0x00000048
 #define VT_BYREF                                0x00004000
    #define VT_CLSIDREF                             0x00004048
xUUID:=uuidcreate()
CONVERT2:=vttype():new(@xUUID,VT_CLSIDREF)

but the error remains.

Many thanks for Your help, surely it allows me to
get closer to the result.
Best regards
Lorenzo
Andreas Gehrs-Pahl
Re: Vttype() and VT_CLSID
on Thu, 01 Feb 2024 21:34:30 -0500
Lorenzo,

Have you tried just:

cValue := UuidFromChar("B96B3CAE-0728-11D3-9D7B-0000F81EF32E")

No need to convert anything any further with vttype(). cValue is already the 
correct VT_CLSID format. All you need to do is to pass it by reference to 
your AxtiveX or COM function.

Hope that makes it a little more clear.

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Lorenzo SucciRe: Vttype() and VT_CLSID
on Sat, 03 Feb 2024 22:33:31 +0100
I keep time to make more test.
Your message "no need to convert anything" is correct.
Alaska programmers have done a powerful interface to ActiveX.
I misunderstand that WIA Automation has a
behavior particular; when I try to change resolution

    oProp := oScanner:items(1):properties(i)    obj AutomationObject
     if oProp:name=="Horizontal Resolution"
       OLDVAL:=oProp:value    ==> num 300
       oProp:value:=150
       NEWVAL:=oProp:value    ==> num 150
    endif

works,(not with all scanners) but when I try to change output
format, I receive an error, it accepts only BMP format

    if oProp:name=="Format"
       wiaFormatBMP	:="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"
       wiaFormatPNG	:="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
       wiaFormatGIF	:="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"
       wiaFormatJPEG	:="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
       wiaFormatTIFF	:="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"
       OLDVAL:=oProp:value    ==> char 
"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"   BMP
       oProp:value:=OLDVAL    ==> ok no error
       oProp:value:=wiaFormatJPEG    ==> error
    endif

I deduced that it was my programming error, and
I was searching a different approach (Vttype ...)
Testing on another PC, with different Windows version and
scanners I see differences, I'm trying to figure out if
it depends on scanner specific driver; furthermore I see
in various programs written in other languages frequent
encapsulation of WIA calls between "try ... catch" structures.
Or this change of format is not to made with this function,
but when I acquire (Transfer/AcquireImage).
Many thanks.
Lorenzo




Il 02/02/2024 03:34, Andreas Gehrs-Pahl ha scritto:
> Lorenzo,
> 
> Have you tried just:
> 
> cValue := UuidFromChar("B96B3CAE-0728-11D3-9D7B-0000F81EF32E")
> 
> No need to convert anything any further with vttype(). cValue is already the
> correct VT_CLSID format. All you need to do is to pass it by reference to
> your AxtiveX or COM function.
> 
> Hope that makes it a little more clear.
> 
> Andreas
Andreas Gehrs-Pahl
Re: Vttype() and VT_CLSID
on Sun, 04 Feb 2024 08:40:29 -0500
Lorenzo,

As I haven't seen much of your code, I have to guess a little bit, but I 
think that what you are doing is enumerating the supported formats of your 
device. All devices must support the BMP format, but they might also support 
others. 

Your code shows:

   if oProp:name=="Horizontal Resolution"

which doesn't seem right. I assume you mean "HorizontalResolution"?

Similarly, your code shows:

   if oProp:name=="Format"

which doesn't seem right either. I assume you mean either "Formats" or 
"FormatID"? 

The "Formats" property is a collection and can be iterated through with a 
Count and Item, giving you all supported formats. You can't assign anything 
to this property or its sub-items, as they are read-only.

The "FormatID" is available in several areas, and either identifies what 
format you want to get when you create/scan an image or what the format of 
a returned image is. If you specify an unsupported image format, the default 
format, probably BMP, will be used for the returned image. This property of 
the image is also read-only!

So, I suggest that you check what formats your device supports, using the 
Formats collection, and then specify one of those available FormatID options 
in the corresponding methods, like "ShowAcquireImage()", "ShowTransfer()", 
and "Transfer()".

But even if you get a BMP returned, you can always convert it to JPEG, or 
whatever you like, when saving the image with Xbase++.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[L]:   https://www.LinkedIn.com/in/AndreasGehrsPahl
[F]:   https://www.FaceBook.com/AbsoluteSoftwareLLC
Lorenzo SucciRe: Vttype() and VT_CLSID
on Tue, 13 Feb 2024 06:26:58 +0100
Thanks for Your observations.
I made some tests and the code here enclosed is working, with 2 
different scanners(Canon 9000 and HP 7610).
I am studying the WIA objects in free times, and this program is
a work in progress, possibly useful to someone at my starting
level.
Yes, saving with XBPImage methods is an alternative.
Best regards
Lorenzo


Il 04/02/2024 14:40, Andreas Gehrs-Pahl ha scritto:
> Lorenzo,
> 
> As I haven't seen much of your code, I have to guess a little bit, but I
> think that what you are doing is enumerating the supported formats of your
> device. All devices must support the BMP format, but they might also support
> others.
> 
> Your code shows:
> 
>     if oProp:name=="Horizontal Resolution"
> 
> which doesn't seem right. I assume you mean "HorizontalResolution"?
> 
> Similarly, your code shows:
> 
>     if oProp:name=="Format"
> 
> which doesn't seem right either. I assume you mean either "Formats" or
> "FormatID"?
> 
> The "Formats" property is a collection and can be iterated through with a
> Count and Item, giving you all supported formats. You can't assign anything
> to this property or its sub-items, as they are read-only.
> 
> The "FormatID" is available in several areas, and either identifies what
> format you want to get when you create/scan an image or what the format of
> a returned image is. If you specify an unsupported image format, the default
> format, probably BMP, will be used for the returned image. This property of
> the image is also read-only!
> 
> So, I suggest that you check what formats your device supports, using the
> Formats collection, and then specify one of those available FormatID options
> in the corresponding methods, like "ShowAcquireImage()", "ShowTransfer()",
> and "Transfer()".
> 
> But even if you get a BMP returned, you can always convert it to JPEG, or
> whatever you like, when saving the image with Xbase++.
> 
> Hope that helps,
> 
> Andreas


testscan.prg