Article View: free.it.visual-basic
Article #2753Re: chiave registro di sistema
From: Malavon Despana
Date: Mon, 10 Mar 2003 23:30
Date: Mon, 10 Mar 2003 23:30
75 lines
3684 bytes
3684 bytes
questa � follia pura, utilizza il WSH � pi� diretto e affidabile :) "Grifisx" <Hell2@you.it> ha scritto nel messaggio news:JuJ5a.215785$0v.6033825@news1.tin.it... > Ti do un codice semplice da usare : ) cmq cerca in giro il registro.bas e > capisci come usarlo � un modulo indispensabile per agire sul registro. > > ' -----------Metti in un > Modulo-------- > '* > ' Esempio di creazione chiave per l'autopartenza di un exe tramite > registro /run > ' > Attribute VB_Name = "mdlAutoRun" > 'PUT THIS IN A .BAS MODULE, OR CHANGE DECLARATIONS TO PRIVATE > > Public 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 > > Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal _ > hKey As Long) As Long > > Public 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 > > Public Const HKEY_CURRENT_USER = &H80000001 > Public Const KEY_WRITE = &H20006 > Public Const REG_SZ = 1 > ' > ' ----------------------------Fine > Modulo----------------------------- > > Da mettere nel codice : > > ' ----------Inserire nel > codice-------- > '* > ' Esempio di creazione chiave per l'autopartenza di un exe tramite > registro /run > ' > Dim hregkey As Long > Dim subkey As String > Dim stringbuffer As String > > subkey = "Software\Microsoft\Windows\CurrentVersion\Run" > > retval = RegOpenKeyEx(HKEY_CURRENT_USER, subkey, 0, _ > KEY_WRITE, hregkey) > If retval <> 0 Then > Debug.Print "Can't open the subkey" > Exit Sub > End If > r$ = "c:\programmi\gryfappunti" > stringbuffer = r$ & "\" & App.EXEName & ".exe" & vbNullChar > retval = RegSetValueEx(hregkey, "My App", 0, REG_SZ, _ > ByVal stringbuffer, Len(stringbuffer)) > > RegCloseKey hregkeySub > ' > ' ---------Fine Codice------------ > > Il codice crea la kiave in "Software\Microsoft\Windows\CurrentVersion\Run" > per autoavviare il proramma "c:\programmi\gryfappunti" che ho fatto per > farmi apaprire un post it ad ogni avvio di winz ^_^ tu puoi modificare le > HKEY path a secondo di come servano a te per cgggiungere la chiave che > vuoi. > >
Technical Details
Message-ID:
<b4j76u$koj$1@lacerta.tiscalinet.it>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!draco.tiscalinet.it!not-for-mailReferences:
<3Ij3a.119738$YG2.3383472@twister1.libero.it> <JuJ5a.215785$0v.6033825@news1.tin.it>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f94ee,5bfbc7578a5220bb X-Google-Attributes: gidf94ee,public X-Google-ArrivalTime: 2003-03-10 15:30:54 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!news.mailgate.org!draco.tiscalinet.it!not-for-mail From: "Malavon Despana" <malCANCELLAILMAIUSCOLOavon@tiscali.it> Newsgroups: free.it.visual-basic Subject: Re: chiave registro di sistema Date: Tue, 11 Mar 2003 00:30:33 +0100 Organization: Tiscali Spa Lines: 77 Message-ID: <b4j76u$koj$1@lacerta.tiscalinet.it> References: <3Ij3a.119738$YG2.3383472@twister1.libero.it> <JuJ5a.215785$0v.6033825@news1.tin.it> NNTP-Posting-Host: ppp-62-10-56-189.dialup.tiscali.it X-Trace: lacerta.tiscalinet.it 1047339038 21267 62.10.56.189 (10 Mar 2003 23:30:38 GMT) X-Complaints-To: newsadmin@it.tiscali.com NNTP-Posting-Date: 10 Mar 2003 23:30:38 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106