' Qregistry için örnek program
' Kullanımdan doğan zararlar için sorumlu kullanan kişidir
' Garantisi yoktur

' QREGISTRY Component sample program
' Warning: No Warranty.
' sorry my bad english

' © 2001 Mesut Akcan
' 1 April 2001
' makcan@softhome.net
' http://kaynak.cjb.net
' http://makcan.virtualave.net

$typecheck on

Const HKEY_CLASSES_ROOT  = &H80000000
Const HKEY_LOCAL_MACHINE = &H80000002 

const ctab = chr$(9) ' Tab character
const clf = chr$(10) ' Line Feed Chr
DIM Registry as QRegistry

DECLARE SUB Button1Click (Sender AS QBUTTON)
DECLARE SUB Button2Click (Sender AS QBUTTON)
DECLARE SUB Button3Click (Sender AS QBUTTON)
DECLARE SUB Button4Click (Sender AS QBUTTON)
DECLARE SUB Button5Click (Sender AS QBUTTON)
DECLARE SUB Button6Click (Sender AS QBUTTON)
DECLARE SUB Button7Click (Sender AS QBUTTON)
DECLARE sub listele(adres as string)

CREATE Form AS QFORM
    Caption = "Qregistry Sample"
    Width = screen.width
    Height = 267
    Center
    CREATE Button1 AS QBUTTON
        Caption = "Windows açılışta çalışan programlar"
        'Running on Win Startup 
        Left = 9            
        Top = 7
        Width = 203
        OnClick = Button1Click
    END CREATE
    CREATE Button2 AS QBUTTON
        Caption = "Bilgisayar adı" 'Computer Name
        Left = 9
        Top = 39
        Width = 203
        TabOrder = 1
        OnClick = Button2Click
    END CREATE
    CREATE Button3 AS QBUTTON
        Caption = "Birincil ekran kartı" 'First Video Adapter
        Left = 9
        Top = 71
        Width = 203
        TabOrder = 2
        OnClick = Button3Click
    END CREATE
    CREATE Button4 AS QBUTTON
        Caption = "Birincil modem" 'First Modem
        Left = 9
        Top = 103
        Width = 203
        TabOrder = 3
        OnClick = Button4Click
    END CREATE
    CREATE Button5 AS QBUTTON
        Caption = "Windows bilgileri" 'Windows Info
        Left = 9
        Top = 135
        Width = 203
        TabOrder = 4
        OnClick = Button5Click
    END CREATE
    CREATE rt1 AS qrichedit
        Left = 220
        Top = 10
        height = 212
        width = screen.width - 235
        wordwrap=0
        scrollbars=3
        font.name="courier"
        text="Mesut Akcan" + clf + "http://kaynak.cjb.net"
    END CREATE
    CREATE Button6 AS QBUTTON
        Caption = "Her tür dosyayı notepad ile aç" 
        ' View all file with Notepad
        Left = 9
        Top = 167
        Width = 203
        TabOrder = 6
        OnClick = Button6Click
    END CREATE
    CREATE Button7 AS QBUTTON
        Caption = "Her tür dosyayı notepad ile aç(İptal)" 
        ' View all file with Notepad (Cancel)
        Left = 9
        Top = 199
        Width = 203
        TabOrder = 6
        OnClick = Button7Click
    END CREATE
END CREATE

Form.ShowModal
'-------------------------------------------
SUB Button1Click (Sender AS QBUTTON)
'win açılışta çalışan
' Running programs, Win on Startup
Registry.RootKey = HKEY_LOCAL_MACHINE 
rt1.text=""
Call listele("Run")
Call listele("RunOnce")
Call listele("RunOnceEx")
Call listele("RunServices")
Call listele("RunServicesOnce")
END SUB

'-------------------------------------------
SUB listele(adres as string)
dim i as short, txt as string,regitem as string , adres2 as string
adres2="Software\Microsoft\Windows\CurrentVersion\" + adres
with Registry
    .OpenKey(adres2, 0)
    txt=""
    FOR i = 0 to .ValueItemCount - 1
        regitem = .ValueItem(I)
        txt = txt + regitem + ctab + .readstring(regitem) + clf
            NEXT  
    txt = string$(60,"-")+ chr$(10)+ adres + chr$(10) + string$(60,"-") + chr$(10)+ txt
    rt1.addstring txt
    .closekey
end with
end sub

'-------------------------------------------
SUB Button2Click (Sender AS QBUTTON)
'bilgisayar adı   
'computer name (on network)
with Registry
    .RootKey = HKEY_LOCAL_MACHINE 
    .OpenKey("System\CurrentControlSet\Control\ComputerName\ComputerName", 0)
    rt1.text="Bilgisayar adı:" +chr$(9) + .readstring("ComputerName")
            ' ^ Computer name
    .closekey
end with
END SUB

'-------------------------------------------
SUB Button3Click (Sender AS QBUTTON)
' ekran kartı   
' Video Graphics Adapter
dim adres as string, txt as string
dim m as integer
with Registry
    .RootKey = HKEY_LOCAL_MACHINE 
    adres = "System\CurrentControlSet\Services\Class\Display\0000"
    .OpenKey(adres, 0)
        'Driver description
    txt = "Sürücü tanımı : " + ctab + .readstring("DriverDesc") + clf
        'Driver date
    txt =txt + "Sürücü tarihi : " + ctab + .readstring("DriverDate")+ clf
    .closekey
    adres = adres + "\INFO"
    .OpenKey(adres, 0)
    txt =txt + "Chip Tipi : " + ctab + .readstring("ChipType")+ clf
    m = .readinteger("VideoMemory")
    m = m / &H100000
        ' Memory Size (Mb)
    txt =txt + "Bellek : " + ctab + str$(m) + " Mb"
    rt1.text=txt
    .closekey
end with
END SUB

'-------------------------------------------
SUB Button4Click (Sender AS QBUTTON)
' birincil modem
' Modem
dim adres as string, txt as string
dim m as integer
with Registry
    .RootKey = HKEY_LOCAL_MACHINE 
    adres = "System\CurrentControlSet\Services\Class\Modem\0000"
    .OpenKey(adres, 0)
        'Driver desc.
    txt = "Sürücü tanımı : " + ctab + .readstring("DriverDesc") + clf
        'driver date
    txt =txt + "Sürücü tarihi : " + ctab + .readstring("DriverDate")+ clf
    .closekey
    rt1.text=txt
end with
END SUB

'-------------------------------------------
SUB Button5Click (Sender AS QBUTTON)
'windows bilgileri
'Win info
dim txt as string
with Registry
    .RootKey = HKEY_LOCAL_MACHINE
    .OpenKey("Software\Microsoft\Windows\CurrentVersion", 0)
    txt = "Versiyon : " + ctab + .readstring("Version")+ clf _
        + "Versiyon no: " + ctab + .readstring("VersionNumber")+ clf _
        'Product Name
        + "Ürününün adı: " + ctab + .readstring("ProductName")+ clf _
        'Product Key
        + "Ürününün anahtarı: " + ctab + .readstring("ProductKey")+ clf _
        'Product Id.
        + "Ürününün kodu: " + ctab + .readstring("ProductId")+ clf _
        'Registered Owner
        + "Kayıtlı kişi adı: " + ctab + .readstring("RegisteredOwner")+ clf _
        'Registered Organization
        + "Şirketi: " + ctab + .readstring("RegisteredOrganization")
    rt1.text=txt
    .closekey
end with
END SUB

'-------------------------------------------
SUB Button6Click (Sender AS QBUTTON)
' tüm dosyaları notepad ile aç
' Open all files with Notepad
with Registry
    .RootKey = HKEY_CLASSES_ROOT
    .OpenKey("*\shell\notepad\command",1) 
    .WriteString("", "Notepad.exe %1")
    .closekey
    .OpenKey("*\shell\notepad",1)
    .WriteString("", "&Not Defteriyle Aç")'Open with Notepad
    .closekey
end with
showmessage "İşlem Tamam" + cLf _ 
 + "Artık her tür dosyayı sağ tıkladığınızda Not defteriyle açabilirsiniz"
 'OK. Now. if you are right click on filename (in explorer file list), shown "Open with Notepad"
END SUB

'-------------------------------------------
SUB Button7Click (Sender AS QBUTTON)
' tüm dosyaları notepad ile aç(iptal)
' Open all files with Notepad (Cancel)
with Registry
    .RootKey = HKEY_CLASSES_ROOT
    .OpenKey("*\shell\notepad\command",1) 
    .DeleteKey("")
    .closekey
    .OpenKey("*\shell\notepad",1)
    .DeleteKey("")
    .closekey
end with
showmessage "İşlem Tamam" + cLf _ 
 + "Her tür dosyay Not defteriyle açma özelliği silindi"
 'OK. Open all files with Notepad (Cancelled)
END SUB

