GetProcessID trouble. menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Jens's Avatar Contributor
    Reputation
    179
    Join Date
    Sep 2006
    Posts
    251
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GetProcessID trouble.

    hello there, this forum seems somewhat deserted, but im trying out anyways

    Code:
    string convStr = listBox1.SelectedItem.ToString();
    IntPtr hWnd = (IntPtr)Convert.ToInt32(convStr);
    label1.Text = GetProcessID(hWnd).ToString();
    is my problem, as far as i found out i need the intptr convertion for changing the input from the listbox into the handle hWnd, and afterwards print it to the lable, but i somehow cant figure out how to do it, i get an error about the input string being a wrong format, i know i could use the FindWindow using pinvoke, but the point is only knowing the process handle not the process id nor window handle, hope to see some response =)

    GetProcessID trouble.
  2. #2
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly, GetProcessID doesn't use an IntPtr, just a plain old int.

    Now, that isn't a whole lot of info to really be of help in solving your problem. When exactly are you trying to do?

  3. #3
    Jens's Avatar Contributor
    Reputation
    179
    Join Date
    Sep 2006
    Posts
    251
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know it returns an int, but im trying to pick a process from the processlist (listbox) grabbing the process handle and getting the processID from that handle, mainly its for learning, i experiment with all sorts of things :P

    [DllImport("kernel32.dll")]
    static extern int GetProcessID(IntPtr hWnd);


    is what i used for importing it, might have something wrong with it, im not that advanced yet, still learning

  4. #4
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hah that explains it. Don't use DllImports for process work. Use the System.Diagnostics namespace. (More importantly, the Process class within that namespace)

    Quick little snippet of how to grab the entire list of processes from the current machine.

    Code:
            public Dictionary<Process, int> ProcessDictionary;
            public void GetProcesses()
            {
                if (ProcessDictionary == null)
                {
                     ProcessDictionary = new Dictionary<Process, int>();
                }
                Process[] processes = Process.GetProcesses(Environment.MachineName);
                foreach (var process in processes)
                {
                    ProcessDictionary.Add(process, process.Id);
                }
             }

Similar Threads

  1. Glider Trouble
    By Kirin in forum World of Warcraft General
    Replies: 3
    Last Post: 01-05-2007, 07:06 AM
  2. Glider trouble
    By Kirin in forum World of Warcraft Bots and Programs
    Replies: 0
    Last Post: 01-04-2007, 06:00 PM
  3. trouble finding .blp
    By yellowsn in forum WoW ME Questions and Requests
    Replies: 5
    Last Post: 11-23-2006, 12:06 AM
  4. Blizz is in some trouble. youll love this :)
    By WoWLegend in forum World of Warcraft General
    Replies: 23
    Last Post: 09-26-2006, 08:01 AM
All times are GMT -5. The time now is 01:56 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search