Testing File Associations?
hi
i have modified some file association code found on this forum so that when i dbl_click a file it will open in my program.
my question is do i have to compile the program before i can see if this works? i ask because at the moment the file does not look as though it has been associated and dbl_clicking on it brings up the box 'cant find the file..' which i assume is obvious since the actual.exe is not there...
so can i test this another way to make sure it definitely works?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Vba && File Associations...
Help!! I'm tearing my hair out with this VBA crap!! I have all kinds of code that works dandy in VB6 but alot of it won't work in VBA. I'm having to use the 'Shell' command in VBA instead of 'ShellExecute' to fire up another application but VBA won't execute the dang application, I think because it has a file extension that's not *.exe. VB6 will execute the other application fine but VBA just yacks up an error message. Is there any way to force VBA to recognize the file association in windoze so it will execute? My application is a high dollar mapping program not any of the M$ Office programs.
Thnx.
Please Help {file Associations}
Hi
I have just about finished my program in which you can save your file as a different extension, so if anyone should take your work to their computer etc they can't open it, anyway...
How do you make is so when the program is closed and you double click the .txt file of in my case MESD file it will open in the program, when i do it, it opens the program and it is blank
Thanks Alot
Michael Eddy (A Newbie)
File Associations
I have tried to research this but haven't really found quite what I'm looking for.
Question #1:
I am using INNO setup to distribute my app, is there a way to script the installation to automatically associate certain file extensions with my app during installation?
Question #2:
Once my files are associated with my app, how can I load a file in my app if the user opens the file? I know I have to use shell commands but I'm not really sure how, an example would be great.
Thank you for the info.
File Associations
This may be a simple question, but I have never encountered this as of yet. I have a Public Sub called OpenProject where my program opens a file through an event triggered by the user (i.e. Open Project from File Menu or Toolbar). What if I have a file extension associated with my program and the user opens it through windows, how do I set it up that my program loads and automatically calls the OpenProject routine for the file selected? Is this done somehow in Sub Main or in the MDIMain_Load event?
Arg, File Associations
When I double click a file say and mp3, Winamp opens the file up and plays it. So my question to anyone that can answer, is how do I do this with my program (presumably using the %1 thingy in file associations)
File Associations
Hi,
How can i add 2 items on the right click menu in windows explorer for all files eg (Encrypt with <MY PROGRAM> ) and (Decrypt with <MY PROGRAM> ) though the registry.
Thanks in advance
the_vb_man
File Associations
hi,
I know how to add my program to the context menu u get when you right on a file in windows explorer for a certain extentions, but is there a way i can add it to all extenstions.
Thanks In Advance
THE VB MAN
File Associations
how do i make it so that my program can open serten files when you click like the TXT file?
Help With File Associations
Hey everyone, I recently made a program thats kinda like winamp, you can put songs and videos and other media into a playlist and the player will scroll through it playing them, but I have a slight problem with associating media files with the program. I have gotten it so that when I double click on an mp3 file, my program will open, but what I want it to do is load the file into the playlist and start playing it. Does anyone have any help or suggestions for this? Thanks
--Smartball
File Associations
question 1
Code:
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Declare Function RegCreateKey Lib _
"advapi32.dll" Alias "RegCreateKeyA" _
(ByVal hKey As Long, ByVal lpSubKey As _
String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib _
"advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx Lib _
"advapi32.dll" Alias "RegSetValueExA" _
(ByVal hKey As Long, ByVal _
lpValueName As String, ByVal _
Reserved As Long, ByVal dwType _
As Long, lpData As Any, ByVal _
cbData As Long) As Long
Private Const REG_SZ = 1
Code:
Public Function CreateFileAssociation(AppName As String, _
ByVal AppExtension As String, AppCommand As String) As Boolean
'Parameters:
'AppName = Name of Application
'AppExtension: = File Extension
'AppCommand = Command Line for Application
'Example:
'CreateFileAssociation "Notepad", ".txt", "notepad.exe"
Dim bAns As Boolean
Dim sKeyName As String
Dim sExtName As String
AppExtension = Trim(AppExtension)
If Left(AppExtension, 1) <> "." Then Exit Function
sExtName = Mid(AppExtension, 2) & " File"
bAns = WriteStringToRegistry(HKEY_CLASSES_ROOT, _
AppExtension, "", sExtName)
If bAns Then bAns = WriteStringToRegistry(HKEY_CLASSES_ROOT, _
sExtName & "shellopencommand", "", AppCommand)
CreateFileAssociation = bAns
End Function
Private Function WriteStringToRegistry(hKey As _
Long, strPath As String, strValue As String, _
strdata As String) As Boolean
Dim bAns As Boolean
On Error GoTo ErrorHandler
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(hKey, strPath, keyhand)
If r = 0 Then
r = RegSetValueEx(keyhand, strValue, 0, _
REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(keyhand)
End If
WriteStringToRegistry = (r = 0)
Exit Function
ErrorHandler:
WriteStringToRegistry = False
Exit Function
End Function
Second question -
Comment - Associations are generally meant to be long term things - like as long as PC still runs. If you are turning associations off & on, you're going to cause problems. If other people are running your app, you'll piss them off
Here is how to find what the associated .EXE file is for a given extension FindExecutable api:
Code:
Const MAX_FILENAME_LEN = 260
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim i As Integer, s2 As String
Const sFile = "C:WindowsReadme.txt"
'Check if the file exists
If Dir(sFile) = "" Or sFile = "" Then
MsgBox "File not found!", vbCritical
Exit Sub
End If
'Create a buffer
s2 = String(MAX_FILENAME_LEN, 32)
'Retrieve the name and handle of the executable, associated with this file
i = FindExecutable(sFile, vbNullString, s2)
If i > 32 Then
MsgBox Left$(s2, InStr(s2, Chr$(0)) - 1)
Else
MsgBox "No association found !"
End If
End Sub
Vba && File Associations
Help!! I'm tearing my hair out with this VBA crap!! I have all kinds of code that works dandy in VB6 but alot of it won't work in VBA. I'm having to use the 'Shell' command in VBA instead of 'ShellExecute' to fire up another application but VBA won't execute the dang application, I think because it has a file extension that's not *.exe. VB6 will execute the other application fine but VBA just yacks up an error message. Is there any way to force VBA to recognize the file association in windoze so it will execute? ALso, I know what you're thinking, why not just VB6? Well because it's a fairly small program and I would rather confine it within the application instead of packaging, deploying and possibly creating conflicts in my clients windoze.
Thnx.
File Associations And The MDI
Has anyone out there worked with file associations via an MDI interface? If so, you're my hero
The trouble is that, with an MDI, you only want one instance of your program running. Thus, when Joe double click on a file associated with your program, any second copies of the program that are started need to communicate to the first instance the name of the file that the user is attempting to open, and then that second instance needs to close itself.
I've found a project over at vbAccelerator (I think?) that does this, but the description is rather over my head and I haven't been able to make it work. Plus, he uses some annoying timer DLL that I'd rather stay away from if possible.
All I'm looking for here is a straightforward, not overcomplicated way of implementing file associations with an MDI.
SOMEONE out there HAS to have experience with this
Daniel
File Associations
How can I make a program open the file that I double click on? I am making a database program, but when I double click on the file, it just opens the program with no information from the file in the text boxes. I tried the %1 at the end of the file association like this:
"C:Program FilesStudent Databasesb.exe %1" but it didn't work. How can I fix this?
Thanks in advance.
File Associations?
I asked a question about file associations quite a while ago, but I didnt really get the help that I needed,
I know how to associate my app with a file type,
but how do I open the file in my app?
say I associated *.txt files with my app, how would I open the contents of the text file in a text box in my app?
Thanks,
Dennis Wrenn
File Associations
i know how to create associations!!!!
but i don't know how to open the file, the user clicked on, because i don't know the code for getting the file name....
*crying for help*
File Associations... Etc.
'for your applications, you may need to create file
'associations for your saved data.
'File associations allow your program to be run
'when a file with a certain extension is 'double-clicked
'in explorer. To do this in VB involves a little bit of
Option Explicit
Public Type mnuCommands
Captions As New Collection
Commands As New Collection
End Type
Public Type filetype
Commands As mnuCommands
Extension As String
ProperName As String
FullName As String
ContentType As String
IconPath As String
IconIndex As Integer
End TypePublic
Const REG_SZ = 1
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Declare Function RegCloseKey Lib _
"advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib _
"advapi32" Alias "RegCreateKeyA" (ByVal _
hKey As Long, ByVal lpszSubKey As String, _
phkResult As Long) As Long
Public Declare Function RegSetValueEx Lib _
"advapi32" Alias "RegSetValueExA" (ByVal _
hKey As Long, ByVal lpszValueName As String, _
ByVal dwReserved As Long, ByVal fdwType As _
Long, lpbData As Any, ByVal cbData As Long) As Long
Public Sub CreateExtension(newfiletype As filetype)
Dim IconString As String
Dim Result As Long, Result2 As Long, ResultX As Long
Dim ReturnValue As Long, HKeyX As Long
Dim cmdloop As Integer
IconString = newfiletype.IconPath & "," & _
newfiletype.IconIndex
If Left$(newfiletype.Extension, 1) <> "." Then _
newfiletype.Extension = "." & newfiletype.Extension
RegCreateKey HKEY_CLASSES_ROOT, _
newfiletype.Extension,Result
ReturnValue = RegSetValueEx(Result, "", 0, REG_SZ, _
ByVal newfiletype.ProperName, _
LenB(StrConv(newfiletype.ProperName, vbFromUnicode)))
' Set up content type
If newfiletype.ContentType <> "" Then
ReturnValue = RegSetValueEx(Result, _
"Content Type", 0, REG_SZ, ByVal _
CStr(newfiletype.ContentType), _
LenB(StrConv(newfiletype.ContentType, vbFromUnicode)))
End If
RegCreateKey HKEY_CLASSES_ROOT, _
newfiletype.ProperName, Result
If Not IconString = ",0" Then
RegCreateKey Result, "DefaultIcon", _
Result2 'Create The Key of "ProperNameDefaultIcon"
ReturnValue = RegSetValueEx(Result2, _
"", 0, REG_SZ, ByVal IconString, _
LenB(StrConv(IconString, vbFromUnicode)))
'Set The Default Value for the Key
End If
ReturnValue = RegSetValueEx(Result, _
"", 0, REG_SZ, ByVal newfiletype.FullName, _
LenB(StrConv(newfiletype.FullName, vbFromUnicode)))
RegCreateKey Result, ByVal "Shell", ResultX
' Create neccessary subkeys for each command
For cmdloop = 1 To newfiletype.Commands.Captions.Count
RegCreateKey ResultX, ByVal _
newfiletype.Commands.Captions(cmdloop), Result
RegCreateKey Result, ByVal "Command", Result2
Dim CurrentCommand$
CurrentCommand = newfiletype.Commands.Commands(cmdloop)
ReturnValue = RegSetValueEx(Result2, _
"", 0, REG_SZ, ByVal CurrentCommand$, _
LenB(StrConv(CurrentCommand$, vbFromUnicode)))
RegCloseKey Result
RegCloseKey Result2
Next
RegCloseKey Result2
End Sub
' <<<<<< Form Event Code >>>>>>
Dim myfiletype As filetype
myfiletype.ProperName = "MyFile"
myfiletype.FullName = "My File Type"
myfiletype.ContentType = "SomeMIMEtype"
myfiletype.Extension = ".MYF"
myfiletype.Commands.Captions.Add "Open"
myfiletype.Commands.Commands.Add _
"c:windows
otepad.exe ""%1"""
myfiletype.Commands.Captions.Add "Print"
myfiletype.Commands.Commands.Add _
"c:windows
otepad.exe ""%1"" /P"
CreateExtension myfiletype
'The filetype type is pretty self-explanatory.
'Extension contains the file type extension.
'Proper name is the name of the type, which you would
'refer to the type as (do not use spaces).
'FullName is the description of the file type.
'ContentType is the description that you would see
'in your Internet browser, if you were to download a
'file of this type. You could think of the extension
'as the "shortcut key", the proper name as the "name",
'and the fullname as the "caption".
'This Commands part of the filetype contains
'the "verbs" for the file type. When you right-click on
'a file of this type, you would see these options.
'Open is set as the default "verb", so when you double
'click on the file type, it executes the command associated
'with "Open". You can add others, such as "Print" as needed.
'Be careful with registry editing, as it can have disasterous effects.
File Associations
I woudl like to know how you could associate your program with a certian file extension. like lets say i want to make it so when you click a file with the extension .abc it would open up in my application, how would you do that?
File Associations
Hi, I have built an application and associated a particular file extension with this app. When I double click a file of type "*.ntm" my app fires up and displays the file contents in a window. This works fine the first time. Then if I double click another *.ntm file, another instance of the app fires up. What I want to do is to activate the current instance and tell it to display the file contents.
Does anyone know of a way to do this?
TIA
File Associations
I would like to click on a file in a file list and have the associated application start. I cannot seem to find any documentation on this very common Windows capability.
File Associations And Opening
ok, i've seen plenty of stuff on PSC about how to create a file association with my program. What i can't seem to find anywhere is what to do once the file association is there and the user has clicked on a file they want to open with my program. ie, how do i find out what file the user just clicked on and then run the sub to open it?
The fact that nobody understands you doesn't mean you're an artist.
XP File Associations (Installshield)
My installshield installation file creates file associations for data files including icons etc
The installation creates the associations properly in Win 95 and 98 but didnt on XP. Is there something special affecting XP? Or maybe it is just a quirk with install file that will fix itself on rebuilding... am gonna try a few more times but if anyone knows some obvious reason then pls let me know
XP File Associations <Resolved>
Ive sorted the problem, the icon didn't exist on the XP machine (I have just wasted nearly 4 hours on this...........what a dope!!!)
Dear Gurus.
Kleinsma kindly pointed me in the direction of this Microsoft KB article and got my associations in the bag with Win98 & ME. It worked so beautifully I nearly cried!!
Thing is when using XPHome (yeah I know...!!) the association gets set up so you can open files from explorer, but the apps .EXE icon does not get associated with the files the prog creates (they show up in explorer with the Windows "dont know what this is?" icon)
The information seems to be OK in the registry, well the icon is listed in the progs entry (I dont really know the registry from my A***!!) any how. Does anyone know why this is happening
Here is the article link for convenience:
http://support.microsoft.com/default...;en-us;Q247529
I could really do with some help here!!
Cheers
Ray
Mediaplayer (file Associations)
does anybody know how to make a media file open automatically in a mediaplayer (msdxm.ocx)?
<Edit> lazyjay - added to the topic title to differentiate it </Edit>
Edited by - lazyjay on 11/1/2004 12:43:31 PM
VS Installer - File Associations - Please Help!
Hi,
I am using Visual Studio Installer 1.1 to create an install for my VB project. I create my associations without any problems, i.e. I create my Document Type (lets call it "MyApplication"), then my extension (call it .aaa) which has its command is set to myapp.exe, then my verb 'Open'. The application installs fine, however the problem is that when I double click on one of my saved files with the .aaa extension (or right click and use 'Open'), it is not passing the file path into my application as a command line argument -- it correctly opens the myapp.exe, but does not pass the file path as a command line argument (in my startup object, Sub Main(), I am looking for the keyword "Command" to contain the file path). Does anyone know how I get this to pass the path as a command line argument into myapp? Any help is very much appreciated!
File Extensions And Associations
using the Common dialog ive been saving what are basically txt files but with the extension *.Wap and *.Rap i can save them easy enough but i cant load the files in my program, it just comes up blank unless, i associate them with notepad in windows...
how would i go about associating files with my program and giving each file type a different Icon?
can anyone suggest how to get around or deal with this problem?
gracias
Signature -----------------------------------------------------------------------------------------------------Code:Private Sub Form_Load() 'Print to from, code my problems!
Form1.Print "CanT SleeP!..... MusT PrograM!!!" & vbCrLf & "I need coffee, WhErE iS mY CoFfEe?!"
End Sub 'All things come to and end
------------------------------------------------------------------------------------------------------------------
Edited by - coma on 11/20/2003 3:42:48 PM
Retrieve File Associations
Hi all,
Without jumping through hoops, is there an easy way to retrieve (programmatically) what executable will be run for any given file extension? I've found many ways to create an association, and clever ways to retrieve the *name* of the program that will be run, but seemingly no way to find the path, and name of the executable!
Suppose I want to find out what *file* runs an MDB database.
Because my clients have at least three different versions of Office, the exe path for MSAccess can be in at least three different locations!
(Oh, and I can't use ShellExecute, because of "/" switches at the end...)
All I need is what is the current default program name and path for MDB files!
Any help appreciated,
Mark
File Extensions & Associations
Hi,
One of my self-written Programs stores data in files with a own extension.
I want to make a association, so that I only have to double click on the data file and it is open with my application.
I know how to do this in windows, but i want want my program to check, if theres an association with this file type, and if not, ask, if he should create one (and then do this)
But I don't know
a) how to check an association
b) how to create an association
(with visual baisc)
thx,
Tom
File Type Associations At Install
Hi,
I have completed a media player program, and I want it to be the default app for a lot of media files (from MIDI to MP3 to AVI, and even SWF), but I don't know how to set it as default association at install. I am using Install Maker Pro, which allows you to change registry values, INI values, and string values at install, so it should be easy to do... but I don't know what to change/add. I've looked at code that supposedly does it, but it doesn't seem to work on win2kPro (my version, and the best in my opinion [next to linux, of course]). Could someone give me a list of all the regkeys and/or files i need to edit to change the Open association and icon?
Thanks very much!
Inno Setup - File Associations :)
I am setting a file association on files related to an application I am creating in VB. The setup program I am using is INNO Setup. The code I am using is below. The file association works great, however the icon for the associated files is the same icon as the application. I would like it to be the little application icon (it looks like a peice of paper with the application icon in it). Anyone know what I am doing wrong?
Code:
[Registry]
Root: HKCR; Subkey: ".pmk"; ValueType: string; ValueName: ""; ValueData: "PulseMenuPKFile"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "PulseMenuPKFile"; ValueType: string; ValueName: ""; ValueData: "PulseMenuPK File"; Flags: uninsdeletekey
Root: HKCR; Subkey: "PulseMenuPKFileDefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}PulseMenuPK.exe,0"
Root: HKCR; Subkey: "PulseMenuPKFileshellopencommand"; ValueType: string; ValueName: ""; ValueData: """{app}PulseMenuPK.exe"" ""%1"""
Creating File Extension Associations...
Does anyone know how to create file associations programatically? For example, if my program saves a file with the extension .icu, I want to add the registry keys (or however it's done) so that the system knows that my application will open files of this type.
I'm pretty sure this could be done using notepad and creating a .reg file (which I would like to see if anyone has it), but I would like to do it in my program using code, so that after the program is installed and the user runs it, it creates the associations automatically.
Thanks in advance!!!
Problem With File Associations In Visual Studio Installer
Hi All,
I created a small VB6 application that uses its own file type. I'm using Visual Studio Installer 1.1 to create the setup file, and everything works fine except for the file associations. I don't get any errors neither when building the .msi file nor when installing it, but when I go to the register to check for the new extension, it is not there. Of course, if I doubleclick at any of my files to open it, it doesn't work either.
What I'm doing is very simple so I have no idea what am I doing wrong. In the File Associations window, I added a document type named MyApp.File, under that and extension .mya, and under that a verb open. I've tried many different things but I can't get it to work. I even took the leading period from the extension out, since the readme file for vsi says to do so; nothing has worked so far.
Any ideas?
File Associations And Loading The File
HI. Ive got the whole file association thing figured out. My Prog opens when the file is doubled clicked and it has my icon and all of that.
My problem is, my program is an mp3 player, and althought the program opens when an mp3 is clicked... i cant figure out how to get it to start playing the file automaticaly like with winamp. Any idea how to do this?
Any help is greatly appreciated! Thanks!!
Testing For An In Use File.
I have an app which uses API calls to write to InI files.
What is the best way to test for open files on a server ?
The Open statement ? or is there an API ?
I am looking to write a general function for all types of files.
Thanks
Dom
Testing A File Name
How can I test the first 2 or 3 numbers of a file name.
Such as: if the file name is 1012356.tif or 1003547.tif I want to test for the file that begins with 101 or 100 and move all of each to seperate directories.
thanks
JO
Testing For Existance Of File On Web
Hi World,
I've been using the DIR command to test the existance of a file on my computer :
VB Code:
Dim FileInQuestion As String FileInQuestion = Dir("C:TEST.TXT") If FileInQuestion = "" Then Console.WriteLine("File Does Not Exists") Else Console.WriteLine("File Exists") End If
which has been working fine. But now i'd like to test for existance of a file on the internet : such as http://www.vbforums.com/images/logo.gif .
Obviously the DIR command will not test for items like this - is there a function that I can use?
I havent been able to find one, or any suitable solutions while searching these forums,
Thanks for any help!
Iffy.
Testing For Certain File Extensions...
I have loaded two files, eg, file1.txt and file2.txt into two separate variables of type string.
If the file has one of the following extensions (.EXE, .COM, .SYS, .OBJ, .LIB, or .BIN.) , I need it to set a certain checkbox value to 1 (that is, check the checkbox).
If the file does not have one of the above extensions, I need to set a different checkbox to a value of 1.
How do I do this?
Testing Integrity Of Data File
Hi
I'm working on a genetic outcome program which uses data that's stored in a Access database. It's vitally important that the data must not be changed (not even a single letter or sign must be changed) otherwise the genetic outcomes are shot to hell.
I have a password on the database but my understanding is that it's not very secure (I might be wrong!) The database is about 2Mb in size.
How can I determine the integrity of the database from my program. I want to check the database at startup to see if it's 100% unchanged and if it has been fiddled with I want to exit the program rather than give incorrect results. Once the database has been build it will not change again.
Any ideas highly appreciated.
Bezzie
Testing For Errors In File Input
I want to implement error handling in the case of the file not existing, or being corrupt etc.
Can anyone help?
Thanks.
Code:
Dim fileName As String
Dim tS As String
Dim filenum As Integer
filenum = 1
fileName = constants.stylePath
Open fileName For Input As filenum
tS = StrConv(InputB(LOF(filenum), filenum), vbUnicode)
Close filenum
Testing To See If A File Has Been Opened Using CreateTextFile
I have a procedure that writes to a text file using the WriteLine method of the TextStream object.
Along the lines of this:
VB Code:
Dim fso, txtfileSet fso = CreateObject("Scripting.FileSystemObject")Set txtfile = fso.CreateTextFile("c: estfile.txt", True)txtfile.WriteLine("Testing 1, 2, 3.") txtfile.Close
The thing is, I want to be able to test to see if the file is open. I know I could set a flag to indicate it's been opened, but there must be a neat way of testing for it?
I thought it would be something like
VB Code:
If (IsEmpty(txtfile)) Then...
IsEmpty(txtfile) is TRUE before the file is opened, FALSE after it's opened (so we're good at this point), but it remains FALSE even after txtfile.Close
The trouble is that in all the examples I've seen, fso and txtfile aren't explicitly typed. What should they be?
Testing VB File Across Microsoft Operating Systems
Hi
I have created a simple body mass index calculator in VB6 and it runs ok under Windows XP.
I don't have Windows 98, NT or 2000 and need to test out this program on these operating systems.
Can anyone with any of these operating sytems help me out and test my program to see if it is compatible.
Have attached a small zip file (24k)
|