LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows Shell Programming: SHFileOperation

Hi to all

Everytime i run this code it throws an Error (Error 1097),  but i don´t know why. Where can i get info about C++ Fx to LV Call library Fx translation? Some corrections of my program?

I'm running Windows XP, and i want to learn how to use the Windows Shell with little or no use of external LV toolkits.

PD: Maybe someone recognise the front panel, it's the first example of SHFileOperation() of "Visual C++ Windows Shell Programming" by Dino Esposito. Does someone know where can i get the source code? i made a search in the editor's page with no results.
Download All
0 Kudos
Message 1 of 3
(3,909 Views)


@JCFC wrote:
Hi to all

Everytime i run this code it throws an Error (Error 1097),  but i don´t know why. Where can i get info about C++ Fx to LV Call library Fx translation? Some corrections of my program?

I'm running Windows XP, and i want to learn how to use the Windows Shell with little or no use of external LV toolkits.

PD: Maybe someone recognise the front panel, it's the first example of SHFileOperation() of "Visual C++ Windows Shell Programming" by Dino Esposito. Does someone know where can i get the source code? i made a search in the editor's page with no results.


Well, first you are calling SHFileOperation which is an alias for SHFileOperationW on non Win9x systems. You do want to explicitedly link to SHFileOperationA instead since LabVIEW strings are in the current locals ASCII encoding. This should make a real difference already.

Maybe another thing, but I'm not sure about that. The two strings should for safety be terminated by a double NULL character since they can contain a list of NULL terminated paths and the list is itself terminated with an additional NULL character. I'm not sure if the LabVIEW Call Library Node will check if a string is already NULL terminated and in that case drop the additional NULL character it usually appends to C strings when passing them to a DLL.

Also SHFileOperation is one of the worse functions to use from the Windows Shell. It's operation in respect to inconsistent flaga and parameter combinations has changed from horribly wrong in Win 9x to strange and sometimes wrong in Win CE/NT 4 to somewhat inconsistent in W2K/XP. It's a monster of a function. A sane programmer usually chooses to write several functions that do one specific thing each good instead of one function trying to do 20 different things all at the same time.

Rolf Kalbermatter


Message Edited by rolfk on 05-26-2008 08:58 AM
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 3
(3,873 Views)


@JCFC wrote:
Hi to all

Everytime i run this code it throws an Error (Error 1097),  but i don´t know why. Where can i get info about C++ Fx to LV Call library Fx translation? Some corrections of my program?

I'm running Windows XP, and i want to learn how to use the Windows Shell with little or no use of external LV toolkits.

PD: Maybe someone recognise the front panel, it's the first example of SHFileOperation() of "Visual C++ Windows Shell Programming" by Dino Esposito. Does someone know where can i get the source code? i made a search in the editor's page with no results.


Adding this as separate answer since the forum would not let me edit my first post annymore.

Last but not least you have unfortunately a little bad luck with this function. You are passing the different elements of the structure as individual parameters to the function. This would be alright if the function would take the structure as parameter but it takes a pointer to that structure instead. So the only way to make this work is to construct the structure as a memory block in LabVIEW and then pass the pointer to it to the function as single parameter. Since the structure is using all 32 bit elements you could use an array of uInt32 to ease that a little but making pointers to the strings that survive until after the call to the DLL is not trivial too.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 3 of 3
(3,869 Views)