Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    jonnyHS's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    46
    Reputation
    10
    Thanks
    1
    My Mood
    Pensive
    i have an idea of how to do it but it said "you dont have the necesary access" and i even use it like ADM

    Edited: i leave that and i found an information https://msdn.microsof*****m/en-us/libr...imagelist.aspx

    So i did this from that but i have 2 problems:

    1-they always repeat themselves 2 times (the items/process)
    2- i dont have any idea for put all de incons in the column i only didi it with simples pictures :P

    Code:
        Private Sub Listview()
           
            Dim ps() As Process
            Try
                ps = Process.GetProcesses()
                ProcessList.BeginUpdate()
                ProcessList.Clear()
                ProcessLis*****lumns.Add("Name", 100, HorizontalAlignment.Left)
                ProcessLis*****lumns.Add("ID", 60, HorizontalAlignment.Left)
                ProcessLis*****lumns.Add("Priority", 60, HorizontalAlignment.Right)
                ProcessLis*****lumns.Add("Memory", 100, HorizontalAlignment.Right)
                Dim p As Process
                For Each p In ps
    
                    Dim item As New ListViewItem(p.ProcessName, 0)
                    item.SubItems.Add(p.Id.ToString())
                    item.SubItems.Add(p.BasePriority.ToString())
                    item.SubItems.Add(p.WorkingSet64.ToString())
                    ProcessList.Items.AddRange(New ListViewItem() {item})
    
                    ' Create two ImageList objects. 
                    Dim imageListSmall As New ImageList()
                    Dim imageListLarge As New ImageList()
    
                    ' Initialize the ImageList objects with bitmaps.
                    imageListSmall.Images.Add(Bitmap.FromFile("C:\1.png"))
                    imageListLarge.Images.Add(Bitmap.FromFile("C:\3.png"))
    
    
    
                    'Assign the ImageList objects to the ListView.
                    ProcessList.LargeImageList = imageListLarge
                    ProcessList.SmallImageList = imageListSmall
    
                    ProcessList.EndUpdate()
    
                Next p
    
            Catch e As Exception
                MessageBox.Show(e.Message)
            End Try
    
    
        End Sub
    help?
    Last edited by jonnyHS; 12-29-2013 at 06:05 PM.

  2. #17
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    try running the program as admin? And/or running the IDE as administrator.

    Running Visual Studio as normal user (notice error list)

     

    Code:
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim _allProcs() As Process = Process.GetProcesses() '' a list of ALL running processes
            Dim _outString As New System.Text.StringBuilder
            Dim _outError As New System.Text.StringBuilder
    
            _outError.AppendLine("ERROR: ")
            For Each _proc As Process In _allProcs
                Try
                    _outString.AppendLine(_proc.ProcessName & "  id: " & _proc.Id.ToString() & "   file: " & _proc.MainModule.FileName)
                Catch ex As Exception
                    _outError.AppendLine(_proc.ProcessName & "->id: " & _proc.Id())
                End Try
    
            Next
            MessageBox.Show(_outString.ToString() & Environment.NewLine & _outError.ToString())
        End Sub

    Running the IDE as Admin (you are able to access more of the programs).


    Let me know if that helps. Use a Try/Catch block --> If an exception is thrown, it's probably because "Access is denied". If it's a system process, simply ignore it. Use code similar to mine and first see which processes you can't access, and if you can access your game. If you absolutely must get access to the process, try manually calling OpenProcess() and see if you can get a valid handle / with what access rights. When I ran the above code there were only 3 processes which I couldn't access as Admin: "System", "Idle" and some third one.

    edited: I've never used a listview. Good Luck. --you were shown above how to use process.mainmodule.filename to get the icon, and the icon class has a convenient ToBitmap() function. I'm not sure what format/class the listview expects, but I think you have what you need.

    As far as duplicates..create a new List(Of String) (or another 'collection' type that grows automatically), and each time you add a process to the list, also record its .ProcessName and .Id. Then, only add a process to the listView if that name/id haven't already been added to the list. Careful as some programs can/will have several copies running (think multiboxing). Have you every worked with arrays or other containers?

    edit2:
    Dim imageListSmall As New ImageList()
    Dim imageListLarge As New ImageList()

    ' Initialize the ImageList objects with bitmaps.
    imageListSmall.Images.Add(Bitmap.FromFile("C:\1.pn g"))
    imageListLarge.Images.Add(Bitmap.FromFile("C:\3.pn g"))

    'Assign the ImageList objects to the ListView.
    ProcessList.LargeImageList = imageListLarge
    ProcessList.SmallImageList = imageListSmall
    So you're 1) Createing a NEW ImageList, then 2) Adding a BITMAP to it and 3) Assigning the ImageList to the listview. We showed you how to get an ICON object from the filepath, and then you can convert that to a bitmap by calling .ToBitmap() on it. Basically the same as you're already doing (adding a bitmap to the imagelist). That should work the same?

    But there is a problem with your logic...it will erase any icons that are already in the list. ? You create a NEW ImageList and then add 2 images to it. Any images that were in the old list don't get saved. I'm sure you could set your imageList == ListView.Images to get a reference to that list, and just add to it (?) I'm not sure, haven't worked with listviews, sorry. Or use a For loop and add all the process icons to the imagelist in one go.
    Last edited by abuckau907; 12-29-2013 at 06:31 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. HOW do I get these rar files everyone uses?
    By naisa in forum CrossFire Hacks & Cheats
    Replies: 5
    Last Post: 03-06-2010, 06:07 PM
  2. [Question]Getting the process in textbox
    By theavengerisback15 in forum Visual Basic Programming
    Replies: 4
    Last Post: 12-02-2009, 07:56 AM
  3. [TUT] Get running processes and kill them ~~
    By Zoom in forum Visual Basic Programming
    Replies: 2
    Last Post: 11-09-2009, 08:34 AM
  4. Getting a process handle in Kernel Mode
    By radnomguywfq3 in forum C++/C Programming
    Replies: 2
    Last Post: 08-10-2009, 12:03 PM
  5. [Request] Get CA process Handle
    By crazyfool in forum Programming Tutorial Requests
    Replies: 2
    Last Post: 05-30-2009, 05:38 AM