LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call library function node for pasting files

Solved!
Go to solution

Hello, I've been using the call library function node to paste text to and from the clipboard, and works nicely.  Now I'm trying to figure out how to paste a file from the windows file explorer.  So if I highlight a file in the Windows file explorer, and hit Ctrl-C, how would I use the library function node spit out a file path?  It would be even better if I could highlight a bunch of files, and then paste out an array of file paths, but that can wait.  Also, I'm using an MC Listbox, so I can't use the event trigger from drag-drop to a file path control.

Also, I'm using WinXP and LV 7.1.

Thanks,

Pat

0 Kudos
Message 1 of 8
(3,516 Views)

pwalsh2 wrote:

Hello, I've been using the call library function node to paste text to and from the clipboard, and works nicely.


If you were using LV 8.x that would not be necessary - you could use the Application.Clipboard methods. Smiley Wink

 


pwalsh2 wrote:

Now I'm trying to figure out how to paste a file from the windows file explorer.  So if I highlight a file in the Windows file explorer, and hit Ctrl-C, how would I use the library function node spit out a file path?  It would be even better if I could highlight a bunch of files, and then paste out an array of file paths, but that can wait.  Also, I'm using an MC Listbox, so I can't use the event trigger from drag-drop to a file path control.


I don't understand why you're trying to use a Windows SDK function for what seems to be a simple Copy operation.

 

Message 2 of 8
(3,495 Views)

Hi, Thanks for the info.  Sounds like I should make the switch to a later version of LV. 

 

I will use the copy function for this, but first I have to retrieve info from the clipboard.  I want the user to open a windows file explorer, highlight a file, hit Ctrl-C, and then come over to my program, and use a right click menu to paste the file into a MC listbox.  So I have to retrieve the clipboard info. 

 

I've been reviewing the msdn stuff here

 

http://msdn.microsoft.com/en-us/library/ms649039(VS.85).aspx

 

In experimenting, I've found that wiring a 15 to the input of the user32.dll-GetClipboardData, I get the handle to the clipboard object.  Now I just don't know how to convert that to a file path.

Thanks,

Pat

0 Kudos
Message 3 of 8
(3,484 Views)
Why not simply use the File Dialog function? It returns a path that you can insert into your listbox directly. That, to me, would seem to be a whole lot easier that having a user open Windows Explorer, select the file, press Ctrl-C, going over to your program, right-click, and paste.
0 Kudos
Message 4 of 8
(3,475 Views)

I can do that too.  This is a special case, where the file navigation is difficult, and often times the file explorer window is already open.  So the copy-paste would work great.  Thanks.

Pat

0 Kudos
Message 5 of 8
(3,461 Views)

Unfortunately, without delving into the Windows API documentation I don't have a direct answer for you.

 

You may want to consider an alternative, and that is to do drag and drop for your VI. I know examples of doing this have been posted on this forum.

0 Kudos
Message 6 of 8
(3,442 Views)
Solution
Accepted by topic author pwalsh2

UPDATE

 

I had some time to play around with this, and really out of sheer curiosity on my part I whipped up a simple example to do drag and drop from Explorer into LabVIEW. I wrote the code in 7.1, but I only have 7.1 on a virtual machine, and the DragQueryFiles was not working. I don't know if it was due to the fact that I was running in a virtual machine. I did, however, run the code in 8.2 and it works correctly. In 8.2 I was able to drag a set of files onto the VI's front panel, and the array of string populates with the filenames. I'm including it to see if it might work for you. You will need to get the Windows Message Queue Library. Just place the library into the same folder where you uncompress the attached file. 

Message Edited by smercurio_fc on 09-22-2009 03:20 PM
Message 7 of 8
(3,429 Views)

This looks like a great start.  Thanks.  I just downloaded everything, and I can't get it to work in 7.1, but I see what you're doing.  Either I'll be able to make it work, or I'll use this as the reason to upgrade LV.  Thanks again.

0 Kudos
Message 8 of 8
(3,421 Views)