It depends what what size you’re trying to get. If a Structure or MemoryBlock, you can use their Size properties. If something else, you’ll have to calculate it yourself.
My problem is I have to call the function with declare, see below :
Declare Function PvCameraListEx Lib dylibLocation (tPvCameraInfoEx,1,1,?) as CFStringRef
And I don’t really know what they mean by “sizeof(tPvCameraInfoEx)”?
tPvCameraInfoEx is a pointer which should give me the list of camera but I don’t know how to know its size when there is only one camera?
[quote=91821:@Christophe Blanc]
tPvCameraInfoEx is a pointer which should give me the list of camera but I don’t know how to know its size when there is only one camera?[/quote]
A pointer is, that is, a pointer to a memory location. Since Xojo produce 32 bit executables then its size is 32bit.
Sorry, I thought it was a pointer because I am supposed to get information out of it.
What is a structure and how can I retrieve information from it?
And also how can I get its size without “sizeof”?
thanks
[quote=91855:@Christophe Blanc]Sorry, I thought it was a pointer because I am supposed to get information out of it.
What is a structure and how can I retrieve information from it?
And also how can I get its size without “sizeof”?
thanks[/quote]
I just didn’t see a header file there so I have no idea what to post to answer your question
IF you have the header file then somewhere in there is buried a declaration of that type
And from that you can figure out how big it is (and it might be worthwhile to declare a structure that is laid out the same)
//
// Camera interface type (i.e. firewire, ethernet):
//
typedef enum
{
ePvInterfaceFirewire = 1,
ePvInterfaceEthernet = 2,
__ePvInterface_force_32 = 0xFFFFFFFF
} tPvInterface; //4 bytes
//
// Camera information type (extended)
//
typedef struct
{
unsigned long StructVer; // Version of this structure //4
//---- Version 1 ----
unsigned long UniqueId; // Unique value for each camera //4
char CameraName[32]; // People-friendly camera name (usually part name) //32
char ModelName[32]; // Name of camera part //32
char PartNumber[32]; // Manufacturer's part number //32
char SerialNumber[32]; // Camera's serial number //32
char FirmwareVersion[32]; // Camera's firmware version //32
unsigned long PermittedAccess; // A combination of tPvAccessFlags //4
unsigned long InterfaceId; // Unique value for each interface or bus //4
tPvInterface InterfaceType; // Interface type; see tPvInterface //4
} tPvCameraInfoEx;
unsigned long PvCameraListEx
(
tPvCameraInfoEx* pList,
unsigned long ListLength,
unsigned long* pConnectedNum,
unsigned long Size
);
with notes
pList Array of tPvCameraInfoEx, allocated by the caller. The camera list is returned in this array.
ListLength Length of pList array.
pConnectedNum The number of cameras found is returned here. This may be greater than ListLength. Null pointer is allowed.
Size Size of the tPvCameraInfoEx structure
Declare Function PvCameraListEx Lib dylibLocation (tPvCameraInfoEx as ptr, ListLength as integer, byref pConnectedNum as integer, size as integer ) as integer
You might actually call this twice in a row
to see how many are returned
then to get the actual list
since YOU have to figure out how big to make the buffer to hold the list
If you do something like
[code]Declare Function PvCameraListEx Lib dylibLocation (tPvCameraInfoEx as ptr, ListLength as integer, byref pConnectedNum as integer, size as integer ) as integer
dim cameraInfo as memoryBlock
dim listlength as integer
dim connected as integer
dim size as integer = 180
dim result as integer
result = PvCameraListEx (cameraInfo, ListLength, connected, size )
// assuming no error happened (HUGE ASSUMPTION!!!)
// connected should have the number of cameras connected
cameraInfo = new memory block (connected * 180)
result = PvCameraListEx (cameraInfo, connected, connected, size )
// assuming no error happened (HUGE ASSUMPTION!!!)
// camera info should have all the buttes of info about however many cameras were attached
[/code]