How to use VECTOR to output your processes. menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    BitHacker's Avatar Master Sergeant
    Reputation
    13
    Join Date
    May 2012
    Posts
    114
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to use VECTOR to output your processes.

    A little tutorial on how to use vectors.

    Declaration:
    Code:
    vector<elemType> vecName;        --         Creates the empty vector object vecName without any elements
    
    vector<elemType> vecName(otherVecName);     --       Creates the vector object vecName and initializes vecName to the elements of the vector otherVecName. vecName and othervecName are of the same type.
    
    vector<elemType> vecName(size);          --         Creates the vector object vecName of size size. vecName is initialized using the defualt values.
    
    vector<elemType> vecName(n, elem);     --     Creates the vecotr object vecName of size n. vecName is initialized using n copies of the element elem.

    There are only certain functions you can use on vector containers. Which are:

    Code:
    vecName.at(index)      --       Returns the element at the position specified by index.
    
    vecName.[index]         --       Returns the element at the position specified by index.
    
    vecName.front()          --       Returns the first element. (Does not check whether the object is empty.)
    
    vecName.back()         --       Returns the last element. (Does not check whether the object is empty.)
    
    vecName.clear()         --       Deletes all elements from the object.
    
    vecName.push_back(elem)      --        A copy of elem is inserted into vecName at the end.
    
    vecName.pop_back()              --         Delete the last element of vecName.
    
    vecName.empty()                   --         Returns true if the object vecName is empty and false otherwise.
    
    vecName.size()                      --         Returns the number of elements currently in 
    
    vecName.maxsize()               --          Returns the maximum number of elements that can be inserted into the object vecNames.
    This teaches you how to list out the elements of the vector container.

    Code:
    #undef UNICODE
    #include <vector>
    #include <string>
    #include <windows.h>
    #include <Tlhelp32.h>
    #include <iostream>
    
    using namespace std;
    
    int main(void)
    {
        vector<string>processNames;
        PROCESSENTRY32 pe32;
        pe32.dwSize = sizeof(PROCESSENTRY32);
        HANDLE hTool32 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
        BOOL bProcess = Process32First(hTool32, &pe32);
        if(bProcess == TRUE)
        {
            while((Process32Next(hTool32, &pe32)) == TRUE)
                processNames.push_back(pe32.szExeFile);
        }
        CloseHandle(hTool32);
        cout << "Number of Processes: " << processNames.size() << endl;
        cin.ignore(1);
        for(int j = 0; j < processNames.size(); j++)
    	cout << processNames[j] << " " << endl;    
        cout << endl;
        cout << "Press Enter To Exit: " << endl;
        cin.ignore(1);
        return 0;
    }
    The #undef UNICODE disables unicode within the vector container. Otherwise you will get compile errors on visual studio 2010.

    -Bit_Hacker
    Last edited by BitHacker; 05-31-2012 at 07:02 AM.

    How to use VECTOR to output your processes.

Similar Threads

  1. How To Use Baby Spices To Your Raid's Advantage
    By CuT in forum World of Warcraft Guides
    Replies: 11
    Last Post: 12-27-2008, 09:36 AM
  2. How To: Use outside forums for your site.
    By Aelus in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 10-01-2008, 07:52 AM
  3. Guide: How to use/create your own Game Objects
    By Arthas117 in forum WoW EMU Guides & Tutorials
    Replies: 12
    Last Post: 01-22-2008, 12:22 PM
All times are GMT -5. The time now is 01:37 PM. 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