Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Nov 20, 2017 8:42 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: how do you access comments of a file from windows explorer?
PostPosted: Mon Apr 08, 2013 11:33 am 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
I would like to write a program to display the comments field and also the file name of a jpg file that is being displayed as the current desktop background.
I just haven't been able to figure out how to do this or if it is possible.


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Tue Apr 09, 2013 4:29 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
You mean file property comments?

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 10, 2013 11:06 am 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Yes that's what I want.

Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 10, 2013 2:03 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
mandjb wrote:
Yes that's what I want.

Thanks



The Following is VB Code using Windows API. Convert the Types to Structures, Any to Variant, vbnullchar to chr(0), Longs to Integers, and call the path string from GetfolderItem("c:\myimage.png").absolutepath (example). The code will return the Comments/Info only.... dont forget to convert the words "GetFileDescription =" to return left(..... :-) If you have trouble converting the functions, I or someone else here will be glad to help you.

Private Const MAX_PATH = 260

Private Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type

Private Declare Function SHGetFileInfo Lib "Shell32" Alias "SHGetFileInfoA" _
(ByVal pszPath As Any, ByVal dwFileAttributes As Long, psfi As SHFILEINFO, _
ByVal cbFileInfo As Long, ByVal uFlags As Long) As Long

' Returns the description of the specified file/folder
' (for example "Folder", "Executable file", "Bmp Image" and so on)

Function GetFileDescription(ByVal sPath As String) As String
Const SHGFI_TYPENAME = &H400

Dim FInfo As SHFILEINFO

' retrieve the item's attributes
SHGetFileInfo sPath, 0, FInfo, Len(FInfo), SHGFI_TYPENAME
' read the szTypeName field
GetFileDescription = Left$(FInfo.szTypeName, InStr(FInfo.szTypeName & _
vbNullChar, vbNullChar) - 1)
End Function

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 10, 2013 3:23 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Prior to Windows Vista, file-specific comments were stored in an NTFS alternate data stream named 0x05SummaryInformation (that is, the name "SummaryInformation" prefixed by a byte containing the number 5.) In Vista and newer, these details are no longer supported, though they may be present.

Accessing an ADS is pretty easy, simply give the full path of the "parent" file or folder and then a colon (":") followed by the stream name. For example, C:\MyFolder\MyFile.txt:MyStream. You can use the GetFolderItem RB method, or Win32 API calls (e.g. this or this)

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 10, 2013 9:36 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Thanks Matthew,

I will try the conversions and see what I can come up with. I haven't done a lot of programming so this will be quite a
challenge for me.


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 10, 2013 9:46 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Thanks charonn0,

I am using windows 7. That is a lot of code in the two examples. I will try working with them and see what I can do.


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Mon Apr 15, 2013 12:59 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Matthew,

I have to the best of my ability made the conversions but I am not sure I did everything correctly.

Although I need to be able to find the file name of the currently displayed desktop background image to input to this function. Is that possible and if so how?

If this can't be done then there is no need to spin my wheels figuring out how to set up the function correctly.

Thanks,

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Mon Apr 15, 2013 1:54 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
mandjb wrote:
Matthew,

I have to the best of my ability made the conversions but I am not sure I did everything correctly.

Although I need to be able to find the file name of the currently displayed desktop background image to input to this function. Is that possible and if so how?

If this can't be done then there is no need to spin my wheels figuring out how to set up the function correctly.

Thanks,

Mike


If you need the background filename, it's actually copied to another location by windows (thus why you can delete an image after setting it as the background and it still stays the background)...and the name is stored in the registry :-) do a google search and you can locate the paths. If you need help creating a function to automatically obtain this information ill be glad to create one. Ultimately what will you need your software to be able to do? This may be the best place to start since obtaining file comments is outside the realm of what this last post is requesting to achieve. Either way we'll get you steered in the right direction :-)

Backgrounds
http://www.sevenforums.com/themes-style ... tored.html

So we may be able to drop the previously mentioned API as it retrieves file specifics (including, but outside of backgrounds)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Tue Apr 16, 2013 12:04 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
I am using windows 7 and have a folder of jpg images that are set up as a slide show for the background and they change fairly frequently. What I would like to be able to do is at any time be able to have a window popup that has the file name and or the comments so that I can tell where that current picture was taken.

Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 17, 2013 12:00 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
I found a batch file that uses a reg query to get the background file name. I've put it in a shell command but get a syntax error that I can't figure out.
Here is my code. Should this work and if so can you see what the syntax error is?

dim bgfile as string
Dim s As Shell
s = New Shell
s.Execute ("REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource")
bgfile = s.Result

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 17, 2013 2:41 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Ignore my last post. I figured out the syntax error, but now when I run the code I get a "shell timed out" as the result. Any idea what is causing this?

The code now looks like this:

dim bgfile as string
Dim s As New Shell
Dim cmd as string
cmd = "REG QUERY ""HKCU\Software\Microsoft\Internet Explorer\Desktop\General"" /v WallpaperSource"
s.Execute ("cmd")
TextField1.Text = s.Result


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 17, 2013 3:13 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Why not use a RegistryItem?

Dim reg As New RegistryItem("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General", False)
TextField1.Text = reg.Value("WallpaperSource")

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Wed Apr 17, 2013 9:47 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Thanks charonn0 that works real nice. Just what I needed.


Top
 Profile  
Reply with quote  
 Post subject: Re: how do you access comments of a file from windows explor
PostPosted: Thu Apr 18, 2013 3:08 pm 
Offline

Joined: Sun Dec 02, 2012 10:50 pm
Posts: 30
Well here is the code that I have so far. I get a syntax error on the Declare function statement.

'this code gets the file name of the current background displayed. It works just fine
dim bgfile as string
dim bgtext as string
dim comments as string
Dim reg As New RegistryItem("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General", False)
bgfile = reg.Value("WallpaperSource")
bgtext = right(bgfile,len(bgfile)-51)
bgtext = left(bgtext,len(bgtext)-4)
TextArea1.Text = bgtext

' the rest of the code is trying to get the file property comment field and append it to the textarea1. I don't understand this part of the code very will so there are probably a lot of errors.

comments = GetfolderItem(bgfile).absolutepath
TextArea1.AppendText (comments)

'The Following is VB Code using Windows API. Convert the Types to Structures, Any to Variant, vbnullchar to chr(0),
'Longs to Integers, and call the path string from GetfolderItem("c:\myimage.png").absolutepath (example).
'The code will return the Comments/Info only.... dont forget to convert the words "GetFileDescription =" to return left(..... :-)
'If you have trouble converting the functions, I or someone else here will be glad to help you.

'Private Const MAX_PATH = 260

Private Declare Function SHGetFileInfo Lib "Shell32" Alias "SHGetFileInfoA" _
(ByVal pszPath As Variant, ByVal dwFileAttributes As Integer, psfi As SHFILEINFO, _
ByVal cbFileInfo As Integer, ByVal uFlags As Integer) As Integer

' Returns the description of the specified file/folder
' (for example "Folder", "Executable file", "Bmp Image" and so on)

Function GetFileDescription(ByVal sPath As String) As String
Const SHGFI_TYPENAME = &H400

Dim FInfo As SHFILEINFO

' retrieve the item's attributes
SHGetFileInfo sPath, 0, FInfo, Len(FInfo), SHGFI_TYPENAME
' read the szTypeName field
'Return Left Left$(FInfo.szTypeName, InStr(FInfo.szTypeName & _
Return Left(FInfo.szTypeName, InStr(FInfo.szTypeName & _
chr(0), chr(0) - 1
'End Function


here is the file structure that is in module 1, I used a screen capture and then converted it with abbyy fine reader into a word document so I could paste it here. There is probably an easier way but I don't know what that may be.

& Add Menu Handler ® Add Constant fc* Add Event Definition © Add Note [? Add Method <3 Add Property ^Comment



Structures
SHFILEINFO

S Structure SHFILEINFO
Declaration
© hlcon As Integer
© ilcon As Integer
© dwAttributes As Integer
© szDisplayName As String * 260
© szTypeName As String * 80 ®


Offset
0
4
8
12
272


Size 4 4 4
260
80
352


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group