LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a cluster with array to a dll

Solved!
Go to solution

Hi,

 

I'll trying to call GetVersionEX Function from kernel32.dll. (trying to determien OS version)

 

One of the parameters is OSVERSIONINFOEX with the following definition:

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;

 

I am using the Call Library Function Node in Labview with a parameter defined as Type-> Adapt to Type, and Data Format->Handles by Value. (please correct me if this is incorrect).

 

I'm trying to define the OSVERSIONINFOEX structure as a cluster but I'm having trouble on how to define the fixed array szCSDVersion[128] so that it is not a pointer. I've tried it as a byte array initialied to 128 elements and string with 128 dummy chars but both end up being pointers.

 

Attached is my cluster (which doesn't work).

 

Any help would be greatly appreciated in defining this cluster and ultimately calling the dll function to get the OS version info.

 

Thanks,

James

 

Message Edited by James@Prolucid on 02-01-2010 11:29 AM
0 Kudos
Message 1 of 13
(4,506 Views)

I can't think of a way other than passing szCSDVersion as a pointer.

I am curious at what others may propose as an alternative.

0 Kudos
Message 2 of 13
(4,501 Views)

btw. If there is a better way to call the "GetVersionEX" without using a cluster or using another method, please let em know. As I said, the main purpose is to be able to read the OS version information so I can perform unique tasks during the installation of my application based on the OS and service pack info.

 

Thanks,

James

0 Kudos
Message 3 of 13
(4,486 Views)
Solution
Accepted by topic author James@Prolucid
You need to create a cluster of 128 bytes and embed that in your cluster as szCSDVersion; a cluster of all of the same type is the same as a fixed-size array of that type.  The easiest way to do this is to wire an empty cluster of U8 to array to cluster, set the cluster size to 128, and create a constant or control.  Drop that cluster in the correct place inside the cluster that you pass to the DLL.  When you get the result back, you can use cluster to array and array of u8 to string to retrieve the data as a string.
Message 4 of 13
(4,476 Views)

Thanks!!  That did it.

 

Here's a simple copy of what I'm using for anyone interested.

 

Thanks,

James

Download All
0 Kudos
Message 5 of 13
(4,470 Views)

Hi 

I am facing the same problem as explained in this thread.

I could not understood this below solution.

"The easiest way to do this is to wire an empty cluster of U8 to array to cluster, set the cluster size to 128, and create a constant or control. "

 

Can anyone explain in detail what is the solution for these kind of problems?

 

 

0 Kudos
Message 6 of 13
(4,043 Views)

Hi

I am facing the same problem.

I have labview 7.1 version.I don't have labview 9.0 version hence i am not able to open the solution example attached here. 

Please provide me the solution vi which can be opened with labview 7.1 version.

0 Kudos
Message 7 of 13
(4,042 Views)

@22445466 wrote:
I could not understood this below solution.

"The easiest way to do this is to wire an empty cluster of U8 to array to cluster, set the cluster size to 128, and create a constant or control. "

 

Can anyone explain in detail what is the solution for these kind of problems?


Sorry, I made an error in that sentence.  It should say "wire an empty array of U8..."  "Array to Cluster" is a built-in LabVIEW function.

 

I don't have a version of LabVIEW old enough to save the posted code back to 7.1, but you could try asking in the Downconvert VI Requests thread.

0 Kudos
Message 8 of 13
(4,033 Views)

Yeah i assumed that its empty array of U8 and i tried like that.

I have wired empty array of U8 to "array to cluster" and created a indicator which is cluster and i have set cluster 

size to 6 since i need array of 6 elements.

But after that how to put this data in the actual cluster with existing parameters.

But is it possible to drag and drop one cluster into another?I tried drag and drop it does not work.

 

Could anybody tell me options to pass data to the cluster from cluster?

 

0 Kudos
Message 9 of 13
(4,020 Views)

@22445466 wrote:

Yeah i assumed that its empty array of U8 and i tried like that.

I have wired empty array of U8 to "array to cluster" and created a indicator which is cluster and i have set cluster 

size to 6 since i need array of 6 elements.

But after that how to put this data in the actual cluster with existing parameters.

But is it possible to drag and drop one cluster into another?I tried drag and drop it does not work.

 

Could anybody tell me options to pass data to the cluster from cluster?

 


There is no problem embedding one cluster inside another cluster, and you should be able to drag one cluster into another.  Can you be more specific than "does not work"?  If the target cluster is a type definition then you will not be able to add items to it on the front panel, because it is locked to the type definition - is this your problem?  If so, you need to modify the type definition.

0 Kudos
Message 10 of 13
(4,014 Views)