Avatar billede simon_jacobsen Nybegynder
04. september 2001 - 14:10 Der er 11 kommentarer og
1 løsning

program filer

hvordan laver man sådan at alle filer med et bestemt \"efternavn\" for det samme icon og når man trykker på iconet skal programmet åbne ?

hilsen simon
på forhånd tak
Avatar billede egede Nybegynder
04. september 2001 - 14:18 #1
åbn en mappe, gå ind i mappeegneskaber -> filtyper -> [vælg filtype] -> avanceret -> skift ikon
Avatar billede egede Nybegynder
04. september 2001 - 14:24 #2
Er det det der tænkes på?
Avatar billede simon_jacobsen Nybegynder
04. september 2001 - 16:53 #3
nej det er ikke det jeg mener.
som f.eks. programmet word der har alle filer med efternavnet .doc fået et word icon hvordan gør man det ?
på forhånd tak
Avatar billede kedde65 Praktikant
04. september 2001 - 17:02 #4
Du tager en tur ind i registrerings databsen og kigger under HKEY_CLASSES_ROOT her finder du den filtype du efterlyser og ændrer tingene.
Hvis du vil gøre det fra VB kan du bare bruge scripting.runtime objectet.
kedde
Avatar billede egede Nybegynder
04. september 2001 - 17:04 #5
ups, så ikke at det var i visual basic du havde oprette spørgsmålet, undskyld :)
Avatar billede simon_jacobsen Nybegynder
04. september 2001 - 17:19 #6
undskyld jeg forstår ikke lige din beskrivelse af hvordan man gør det i VB :)
Avatar billede jelzin101 Praktikant
04. september 2001 - 17:47 #7
jeg fandt flg. stykke kode:
Option Explicit

\'// Windows Registry Messages
Private Const REG_SZ As Long = 1
Private Const REG_DWORD As Long = 4
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003

\'// Windows Error Messages
Private Const ERROR_NONE = 0
Private Const ERROR_BADDB = 1
Private Const ERROR_BADKEY = 2
Private Const ERROR_CANTOPEN = 3
Private Const ERROR_CANTREAD = 4
Private Const ERROR_CANTWRITE = 5
Private Const ERROR_OUTOFMEMORY = 6
Private Const ERROR_INVALID_PARAMETER = 7
Private Const ERROR_ACCESS_DENIED = 8
Private Const ERROR_INVALID_PARAMETERS = 87
Private Const ERROR_NO_MORE_ITEMS = 259

\'// Windows Security Messages
Private Const KEY_ALL_ACCESS = &H3F
Private Const REG_OPTION_NON_VOLATILE = 0

\'// Windows Registry API calls
Private Declare Function RegCloseKey Lib \"advapi32.dll\" _
(ByVal hKey As Long) As Long

Private Declare Function RegCreateKeyEx _
  Lib \"advapi32.dll\" Alias \"RegCreateKeyExA\" _
(ByVal hKey As Long, _
  ByVal lpSubKey As String, _
  ByVal Reserved As Long, _
  ByVal lpClass As String, _
  ByVal dwOptions As Long, _
  ByVal samDesired As Long, _
  ByVal lpSecurityAttributes As Long, _
  phkResult As Long, _
  lpdwDisposition As Long) As Long

Private Declare Function RegOpenKeyEx _
  Lib \"advapi32.dll\" Alias \"RegOpenKeyExA\" _
(ByVal hKey As Long, _
  ByVal lpSubKey As String, _
  ByVal ulOptions As Long, _
  ByVal samDesired As Long, _
  phkResult As Long) As Long

Private Declare Function RegSetValueExString _
  Lib \"advapi32.dll\" Alias \"RegSetValueExA\" _
(ByVal hKey As Long, _
  ByVal lpValueName As String, _
  ByVal Reserved As Long, _
  ByVal dwType As Long, _
  ByVal lpValue As String, _
  ByVal cbData As Long) As Long

Private Declare Function RegSetValueExLong _
  Lib \"advapi32.dll\" Alias \"RegSetValueExA\" _
(ByVal hKey As Long, _
  ByVal lpValueName As String, _
  ByVal Reserved As Long, _
  ByVal dwType As Long, _
  lpValue As Long, _
  ByVal cbData As Long) As Long


Private Sub CreateAssociation()

  Dim sPath As String

  \'// File Associations begin with a listing
  \'// of the default extension under HKEY_CLASSES_ROOT.
  \'// So the first step is to create that
  \'// root extension item
  CreateNewKey \".xxx\", HKEY_CLASSES_ROOT

  \'// To the extension just added, add a
  \'// subitem where the registry will look for
  \'// commands relating to the .xxx extension
  \'// (\"MyApp.Document\"). Its type is String (REG_SZ)
  SetKeyValue \".xxx\", \"\", \"MyApp.Document\", REG_SZ

  \'// Create the \'MyApp.Document\' item under
  \'// HKEY_CLASSES_ROOT. This is where you\'ll put
  \'// the command line to execute or other shell
  \'// statements necessary.
  CreateNewKey \"MyApp.Document\\shell\\open\\command\", HKEY_CLASSES_ROOT

  \'// Set its default item to \"MyApp Document\".
  \'// This is what is displayed in Explorer against
  \'// for files with a xxx extension. Its type is
  \'// String (REG_SZ)
  SetKeyValue \"MyApp.Document\", \"\", \"MyApp Document\", REG_SZ

  \'// Finally, add the path to myapp.exe
  \'// Remember to add %1 as the final command
  \'// parameter to assure the app opens the passed
  \'// command line item.
  \'// (results in \'\"c:\\LongPathname\\Myapp.exe %1\")
  \'// Again, its type is string.
  sPath = \"c:\\LongPathname\\Myapp.exe %1\"
  SetKeyValue \"MyApp.Document\\shell\\open\\command\", \"\", sPath, REG_SZ

  \'// All done
  MsgBox \"The file association has been made!\"

End Sub

Private Function SetValueEx(ByVal hKey As Long, _
sValueName As String, lType As Long, _
vValue As Variant) As Long

  Dim nValue As Long
  Dim sValue As String

  Select Case lType
    Case REG_SZ
      sValue = vValue & Chr$(0)
      SetValueEx = RegSetValueExString(hKey, _
        sValueName, 0&, lType, sValue, Len(sValue))

    Case REG_DWORD
      nValue = vValue
      SetValueEx = RegSetValueExLong(hKey, sValueName, _
        0&, lType, nValue, 4)

  End Select
 
End Function


Private Sub CreateNewKey(sNewKeyName As String, _
  lPredefinedKey As Long)

  \'// handle to the new key
  Dim hKey As Long
 
  \'// result of the RegCreateKeyEx function
  Dim r As Long
 
  r = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, _
    vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKey, r)

  Call RegCloseKey(hKey)

End Sub


Private Sub SetKeyValue(sKeyName As String, sValueName As String, _
vValueSetting As Variant, lValueType As Long)

  \'// result of the SetValueEx function
  Dim r As Long
 
  \'// handle of opened key
  Dim hKey As Long
 
  \'// open the specified key
  r = RegOpenKeyEx(HKEY_CLASSES_ROOT, sKeyName, 0, _
    KEY_ALL_ACCESS, hKey)

  r = SetValueEx(hKey, sValueName, lValueType, vValueSetting)

  Call RegCloseKey(hKey)

End Sub

Private Sub cmdTest_Click()
  CreateAssociation
End Sub





den registrerer .xxx filer (hmmm lidt skummelt men :)
til c:\\LongPathname\\MyApp.Exe
Avatar billede jelzin101 Praktikant
04. september 2001 - 20:50 #8
tak for pts.
Avatar billede simon_jacobsen Nybegynder
04. september 2001 - 21:09 #9
det var så lidt :)
Avatar billede razersedge Nybegynder
07. september 2001 - 21:50 #10
hmm hvordan får jeg den til at åbne et textdokument i en bestemt txtbox ? hvordan gør jeg det mht til parametre
Avatar billede cellaneous Nybegynder
13. september 2001 - 16:37 #11
Avatar billede cellaneous Nybegynder
13. september 2001 - 16:59 #12
ups nej misforstod dig :-) har sendt dig svar på http://www.eksperten.dk/spm/107053 istedet!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester