?
Solved

get file path to image loaded on clipboard

Posted on 2012-03-13
16
Medium Priority
?
534 Views
Last Modified: 2012-06-21
How do I get local or actual file path to an image of type CF_BITMAP, CF_DIB, CF_TIFF, and CF_ENHMETAFILE currently loaded on the clipboard? I know how to get the actual image but I need to know the file path (If CF_HDROP is not specified as a loaded file type).
0
Comment
Question by:ray_marik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
16 Comments
 
LVL 36

Accepted Solution

by:
mccarl earned 2000 total points
ID: 37717918
I would think that you can't. If the type is one of those CF_BITMAP, etc. then it is ONLY the image data that is on the clipboard, not the file. Hence, there is no file name there for you to retrieve.
0
 

Author Comment

by:ray_marik
ID: 37718092
Well, if it's CF_BITMAP and CF_HDROP loaded, there's a filename you can retrieve, so I would think you could retrieve a file name from other formats also loaded on clipboard along with CF_BITMAP, for example, OLE PRIVATE DATA or UniformResourceLocatorDataW.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37718107
You said in the original post that
If CF_HDROP is not specified as a loaded file type
so that's what I was assuming.

How are these items getting on to the clipboard? Are you talking about, eg. hitting Ctrl+C on an image file in the filesystem? Or otherwise?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ray_marik
ID: 37720120
What I was referring to is that a number of formats are loaded each time, not just what you normally would expect, ie for an image CF_BITMAP is specified but also something like CF_HDROP and a load of others.
Nevermind though, I guess it can't be done.
0
 

Author Comment

by:ray_marik
ID: 37726405
I've requested that this question be deleted for the following reason:

No solution offered, cannot be done.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37723297
Nevermind though, I guess it can't be done.

While that may well be he final outcome, but I hadn't really finished working this through with you. Are you able to answer the question that I asked?

How are these items getting on to the clipboard? Are you talking about, eg. hitting Ctrl+C on an image file in the filesystem? Or otherwise?
0
 

Author Comment

by:ray_marik
ID: 37723306
"How are these items getting on to the clipboard? Are you talking about, eg. hitting Ctrl+C on an image file in the filesystem? Or otherwise?"

Right click, then copy.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37723318
Right click, then copy.

But in what context? Right click on a file in the filesystem? Richt click on an image on a webpage? In a particular program, such as Word, Excel?
0
 

Author Comment

by:ray_marik
ID: 37724862
Right clicking on images inside IE and loading to clipboard is the problem. I thought that was implied bec/ right clicking inside Win Explorer just passes the file as CF_HDROP, (in other words drag and drop and not of type CF_BITMAP).
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37726383
Ok, yeah, I was just making sure that that is the case before saying this...

I guess it can't be done

True, but not because of some limitation of the code or the clipboard, but simply because there is no file path to retrieve! Images in a browser are just image data retrieved from a URL, and they are at no point a file in the filesystem.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37726406
Moderators,

I don't believe that this should be deleted. I agree that there was no solution, but there is still a correct answer, "that there is no file path to retrieve". I believe that that is still worthy of an answer being accepted, and points awarded.
0
 

Author Comment

by:ray_marik
ID: 37726902
There IS a file path to retrieve:

"Right clicking on images inside IE and loading to clipboard" should give a path and a file name leading to the original image inside the IE temp folder. That's how IE retrieves the images. We can argue till the cows come home but there is a file path and name to retrieve.
0
 
LVL 36

Expert Comment

by:mccarl
ID: 37727249
> the original image inside the IE temp folder

What makes you think there is a physical file in the temp folder? Are talking about when you go to C:\Documents and Settings\XXXXX\Local Settings\Temporary Internet Files and you see entries in there for all the cached items, such as images, etc? That is just Windows trying to confuse you, it is presenting the browsers cahced items as though they are files but they aren't actually stored on the disk as files (I not saying that the info is not on the hard drive somewhere, just not as files and not in that directory). It is a view that Windows is making it "look" like there are physical files.

Here is some simple test code to illustrate my point... (go to your view of your Temporary Internet Files directory and pick out a file, put the path to that file as the constructor arg for file2, and put a path to a known file outside of the Temporary Internet Files directory for file1)

import java.io.File;
import java.io.IOException;

public class TestTemporaryInternetFileRetrieval {
	public static void main(String[] args) throws IOException {
		File file1 = new File("C:\\Documents and Settings\\XXXXX\\Local Settings\\test.txt");
		File file2 = new File("C:\\Documents and Settings\\XXXXX\\Local Settings\\Temporary Internet Files\\blank.gif");
		
		System.out.println("file1 exists: " + file1.exists() + " (" + file1.getAbsolutePath() + ")");
		System.out.println("file2 exists: " + file2.exists() + " (" + file2.getAbsolutePath() + ")");
	}
}

Open in new window


You should see that the file outside Temporary Internet Files "exists" and the one inside doesn't, ie. they aren't real files that can be accessed by a file path.
0
 

Author Comment

by:ray_marik
ID: 37727669
IE caches image files inside temp folder for easier access later, that's the whole point.

In fact, back to the point I made in the second comment, assuming that CF_BIMAPT AND CF_HDROP are BOTH specified as loaded clipboard formats, then you can retrive the complete path to the image that points to the IE temp internet file. I have this code and it works as expected.

But what I was trying to do was get image path back to this IE temp folder assuming CF_BITMAP is specified but CF_HDROP is not, which is what happens with some images.

What I've ended up doing here is explain more to you than it's worth to me and my time. Judging by the Java code you cite for a C/C++ question and the fact you keep arguing to win 500 points, I'm led to believe that you do not understand clipboard and its formats and so I'm going to asks the moderators again to delete this question. You have not posted a solution and you do not deserve any points. Good day.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question