Make an Exe as startup

Wednesday, February 18, 2009

Public Sub AutoStartup()
Try
Dim RegKey As RegistryKey
RegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
RegKey.SetValue("DBFT Client", Application.ExecutablePath)

Catch ex As Exception
MakeLog("Putting in Windods Auto Startup " & Application.ExecutablePath, Err.Number, Err.Description)
End Try
End Sub

How To Write an INI File

Module

#Region "APICalls"
' standard API declarations for INI access
Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Int32

Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Int32, _
ByVal lpFileName As String) As Int32

#End Region


Private Sub INIWrite(ByVal INIPath As String, ByVal SectionName As String, ByVal KeyName As String, ByVal TheValue As String)

Call WritePrivateProfileString(SectionName, KeyName, TheValue, INIPath)
End Sub

End Module

Read From INI File

#Region "APICalls"
' standard API declarations for INI access
Private Declare Unicode Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpString As String, _
ByVal lpFileName As String) As Int32

Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringW" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Int32, _
ByVal lpFileName As String) As Int32

#End Region

Private Function INIRead(ByVal INIPath As String, ByVal SectionName As String, ByVal KeyName As String, ByVal DefaultValue As String) As String

' primary version of call gets single value given all parameters
Dim n As Int32
Dim sData As String
sData = Space$(1024) ' allocate some room

n = GetPrivateProfileString(SectionName, KeyName, DefaultValue, sData, sData.Length, INIPath)

If n > 0 Then ' return whatever it gave us
INIRead = sData.Substring(0, n)
Else
INIRead = ""
End If
End Function

List of Available DSN

Tuesday, February 3, 2009

Public Function fGetDSNList() As String()
Dim RegHandle As RegistryKey
Dim Reg As RegistryKey = Registry.LocalMachine
Dim conRegKey1 As String = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\"
Try
RegHandle = Reg.OpenSubKey(conRegKey1)
Return RegHandle.GetValueNames
Catch err As Exception
Msgbox(err.description)
End Try
Exit Function
End Function

Show a list View in Group

Monday, December 29, 2008

This will show the list view Group

Dim ObjListItem As ListViewItem
Dim ObjListViewGroup As ListViewGroup
ObjListViewGroup = New ListViewGroup("File Name :" & FileName)
LvwBills.Groups.Add(ObjListViewGroup)
For iCount = 0 To 10                
                ObjListItem = New ListViewItem(ObjListViewGroup)
                ObjListItem.SubItems.Add("ABCD"              
                LvwBills.Items.Add(ObjListItem)
                PFileProcessBar.Value = iCount
Next