如何获得系统中的一个程序的名字,我用API取出来,要是程序名是中文,就是乱码,不知怎么样才能显示出正确的中文!

解决方案 »

  1.   

    '刷新进程信息
    Private Sub RefreshProcessList()
        Dim myProcess As PROCESSENTRY32
        Dim I As Integer
        Dim mySnapshot As Long
        Dim GEXEStr As String * 260
        frmMain.listProcess.ListItems.Clear
        myProcess.dwSize = Len(myProcess)
        mySnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
        ProcessFirst mySnapshot, myProcess
        
        ReDim ProcessName(1)
        ReDim ProcessPID(1)
        ReDim ProcessLine(1)
        ProcessName(0) = myProcess.szexeFile     '如果是中文程序名得到是不对
        ProcessPID(0) = myProcess.th32ProcessID
        ProcessLine(0) = myProcess.cntThreads    While ProcessNext(mySnapshot, myProcess)
            ReDim Preserve ProcessName(UBound(ProcessName) + 1)
            ReDim Preserve ProcessPID(UBound(ProcessName))
            ReDim Preserve ProcessLine(UBound(ProcessName))
            
            I = UBound(ProcessName) - 1
            ProcessName(I) = myProcess.szexeFile
            ProcessPID(I) = myProcess.th32ProcessID
            ProcessPID(I) = myProcess.cntThreads
        WendEnd Sub