Results 1 to 7 of 7

Thread: FiLeTyPeS, 2 Q's, (Don't need to be guru tu answer this)

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs up

    Ok, i've done some rearch about filetypes in registry, to make my recent app complete. I'm thinking about making a dll, for you that want to create your own filetypes fast and easy. So i have to ask you guys two qwestions.

    1. Have anyone done this already? If, so could you send me the dll (or whatever)

    2. When i'm ready with this, do you want to have my dll? I suppose there must be at least some people out there who have tried to make their own filetypes
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    create your own file type

    '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 "ProperName\DefaultIcon"
    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\notepad.exe ""%1"""
    myfiletype.Commands.Captions.Add "Print"
    myfiletype.Commands.Commands.Add _
    "c:\windows\notepad.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.

    USE AT OWN RISK >>> :>


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Ok, thanks,
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    OK, I have some more Q's here:
    1. The association work's fine, but i have to restart for the icon and file type name to show. How do i update them immediately?
    2. I need to associate to mp3's with two extra commands. I know how to do it but,
    a) Will winamp be affected?
    b) What happens if winamp terminates it's association with mp3's?
    c) If winamp's not installed my assosiation is still needed, but when winamp installs or reassociate with mp3's will it's command appear next to mine? I wan't my commands to be always come in second.
    3. There are two copies of the filetype in registry, in root and localmachine. The second is created automatically, will it also remove automatically, if i terminate my association by removing the keys in the first?

    Also who those who want's to know what i'm doing, i'm still working on my mp3-integrated lyrics editor for winamp.
    And if anyone is still interested in solving my so easy scrolling dilemma, just reply here, (ok it's not that easy as even fox didn't manage to get it work properly)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    I think if you install Winamp after your App. It will erase your commands and replace it with it's own.

  6. #6

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Anyone?!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Lively Member
    Join Date
    Mar 2000
    Location
    Lowestoft
    Posts
    91
    hi, i havent seen ur scrolling lyrics thing, and dont know if this will help you, but i found somehting:

    http://www.dev-center.com/code/code.asp?CodeID=346

    check it out, hope it helps?

    Mag-Net
    Mag-Net's Home
    Visual Studio 6-Enterprise - SP4
    ICQ: 35519773
    Have Fun

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width