Sapete dirmi dove sbaglio?
Il problema è questo: quando vado a scrivere nel registro, la parola viene tagliata... Perché?
Non viene tagliata sempre nello stesso punto; a volte lo i primi 8 caratteri, a volte solo i primi 11, ecc.
Ecco il progetto di eMBedded Visual Basic:
FORM1
Option Explicit
Private Sub Form_OKClick()
App.End
End Sub
Private Sub Command1_Click()
Call Registro(HKEY_CLASSES_ROOT, "jpegimage\Shell\Open\Command", "", Text1.Text)
End Sub
MODULE1
Option Explicit
Declare Function RegCreateKeyEx Lib "Coredll" Alias "RegCreateKeyExW" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegCloseKey Lib "Coredll" (ByVal hKey As Long) As Long
Declare Function RegSetValueEx Lib "Coredll" Alias "RegSetValueExW" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const REG_SZ = 1
Public Const REG_DWORD = 4
Public Sub Registro(hKey As Long, strPath As String, strValue As String, strData As String)
Dim KeyHand As Long
Dim R As Long
R = RegCreateKeyEx(hKey, strPath, 0, vbNullString, 0, 0, 0, KeyHand, 0)
R = RegSetValueEx(KeyHand, strValue, 0, REG_SZ, strData, Len(strData))
R = RegCloseKey(KeyHand)
End Sub
Vi ringrazio!
Berello


Rispondi quotando
