On Sep 13, 11:39 am, "Anil Gupte" <anil-l...@icinema.co mwrote:
I wrote my Windows Service first as a regular Windows Exe because it is
easier to debug. In that I used
AppDir = Application.Exe cutablePath.Sub string(0,
Application.Exe cutablePath.Las tIndexOf("\")) ' Where this application
Excutable sits
Now, when I am converting it to a Service, what path can I use? Or can I
specify a path in the service to always use as a data path? I would prefer
the former because I do not know the layout of the target computer.
--
Anil Guptewww.keenin c.netwww.icinem a.com
Try the WMI class to get Windows Default path
Imports System.Manageme nt
Public Class wmi
Private objOS As ManagementObjec tSearcher
Private objCS As ManagementObjec tSearcher
Private objMgmt As ManagementObjec t
Private m_strComputerNa me As String
Private m_strManufactur er As String
Private m_StrModel As String
Private m_strOSName As String
Private m_strOSVersion As String
Private m_strSystemType As String
Private m_strTPM As String
Private m_strWindowsDir As String
Public Sub New()
objOS = New ManagementObjec tSearcher("SELE CT * FROM
Win32_Operating System")
objCS = New ManagementObjec tSearcher("SELE CT * FROM
Win32_ComputerS ystem")
For Each objMgmt In objOS.Get
m_strOSName = objMgmt("name") .ToString()
m_strOSVersion = objMgmt("versio n").ToString ()
m_strComputerNa me = objMgmt("csname ").ToString ()
m_strWindowsDir = objMgmt("window sdirectory").To String()
Next
For Each objMgmt In objCS.Get
m_strManufactur er = objMgmt("manufa cturer").ToStri ng()
m_StrModel = objMgmt("model" ).ToString()
m_strSystemType = objMgmt("system type").ToString
m_strTPM = objMgmt("totalp hysicalmemory") .ToString()
Next
End Sub
Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerNa me
End Get
End Property
Public ReadOnly Property Manufacturer()
Get
Manufacturer = m_strManufactur er
End Get
End Property
Public ReadOnly Property Model()
Get
Model = m_StrModel
End Get
End Property
Public ReadOnly Property OsName()
Get
OsName = m_strOSName
End Get
End Property
Public ReadOnly Property OSVersion()
Get
OSVersion = m_strOSVersion
End Get
End Property
Public ReadOnly Property SystemType()
Get
SystemType = m_strSystemType
End Get
End Property
Public ReadOnly Property TotalPhysicalMe mory()
Get
TotalPhysicalMe mory = m_strTPM
End Get
End Property
Public ReadOnly Property WindowsDirector y()
Get
WindowsDirector y = m_strWindowsDir
End Get
End Property
Public ReadOnly Property FontDirectory()
Get
FontDirectory = m_strWindowsDir & "\font".ToU pper
End Get
End Property
End Class