LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pointers in Labview calls to Win32 API

I want to  show a browse for folder dialog on the screen with the help of a call to shell32.dll
function :
 
LPITEMIDLIST SHBrowseForFolder(      
    LPBROWSEINFO lpbi
);
 
browseinfo looks like this:
 
typedef struct _browseinfo {
    HWND hwndOwner;
    LPCITEMIDLIST pidlRoot;
    LPTSTR pszDisplayName;
    LPCTSTR lpszTitle;
    UINT ulFlags;
    BFFCALLBACK lpfn;
    LPARAM lParam;
    int iImage;
} BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO;
 
Following the instructions in the help file of labview, every variable should be converted to a string and concatenated to obtain a binary structure comparable with the wanted structure  Problem  is that there are pointers inside this structure. Pointers to string should first be resolved. How can I get pointers to strings etc.?
Or even a solution for passing such a structure.
 
 
 
0 Kudos
Message 1 of 3
(3,011 Views)
Sometimes it is possible to get dll calls working that have the non-standard data types, but this one looks complicated. Your chances are better using later versions of LabVIEW, like 7 or 8.
0 Kudos
Message 2 of 3
(3,002 Views)


@vlipje wrote:
I want to  show a browse for folder dialog on the screen with the help of a call to shell32.dll
function :
 
LPITEMIDLIST SHBrowseForFolder(      
    LPBROWSEINFO lpbi
);
 
browseinfo looks like this:
 
typedef struct _browseinfo {
    HWND hwndOwner;
    LPCITEMIDLIST pidlRoot;
    LPTSTR pszDisplayName;
    LPCTSTR lpszTitle;
    UINT ulFlags;
    BFFCALLBACK lpfn;
    LPARAM lParam;
    int iImage;
} BROWSEINFO, *PBROWSEINFO, *LPBROWSEINFO;
 
Following the instructions in the help file of labview, every variable should be converted to a string and concatenated to obtain a binary structure comparable with the wanted structure  Problem  is that there are pointers inside this structure. Pointers to string should first be resolved. How can I get pointers to strings etc.?
Or even a solution for passing such a structure.


Unless you are a total C crack (and then you wouldn't have asked here I think), forget about doing this in LabVIEW alone. There are several things here why it really will be difficult or even impossible to get away here without a wrapper DLL.

1)
LPCITEMIDLIST is a dynamically allocated special structure used by shell32 to represent paths. To create such PIDLs you have to call at least one more shell32 API and afterwards one to dispose of it. The structure of a PIDL is not really documented so even if you wanted you couldn't create it on your own in LabVIEW.

2)
BFFCALLBACK is a callback function, that means a function pointer. While with lots of magic and all kinds of very involved tricks you could create and manage all kinds of pointers in LabVIEW by calling numerous extra API functions through the Call Library Node, this is something you can't really create in LabVIEW without creating an extra VI that is placed into a DLL and some very special code. Unless you know function pointers in C to a very intimate level this simply is not possible and I'm not going to try to explain how it could be done anyhow since writing that would give an essay of many pages and still be not understandable unless you really know a lot about C.

3) LPARAM is a pointer you use to pass context specific user data to the function which is then passed back to your callback function as one of the parameters.

So simply said if you can't or don't want to create a wrapper DLL then you simply don't want to deal with these difficulties on a LabVIEW diagram level and if you know how to create a wrapper DLL you will certainly choose for that solution as it is a lot simpler now and especially in the long run.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 3 of 3
(2,992 Views)