Thread: help for find some api in C

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    5

    Smile help for find some api in C

    hey guys
    first of all i must apologize, because my english is'nt very good

    i want to find some process api in C.i found something in msdn.microsoft.com but as i said i want them in C.
    here is some examples of what i want: Enumerating All Processes or http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    if U help me to find a good reference of C api functions i become so much appreciate.
    Last edited by desimoos; 05-22-2012 at 01:17 PM.

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Those are in C. I know it says C++, but there is nothing in the code that prohibits you from using them in C programs (C is, roughly, a subset of C++). Also, those pages contain links to the API documentation for the functions EnumProcesses and GetProcessMemoryInfo, which in turn will link you to all the process API functions you need. They will almost certainly all be in C.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    5
    you're right, tanx for your answer
    i find out what is the problem. i copy the msdn's example into the c project but it dosnt work. i asked someone and he told me i should copy psapi.dll (which includes process api functions) into the project folder. but this way did'nt work too.

    please someone tell me how can i fix this problem

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Maybe you should try telling us how it doesn't work. Post your errors and your code!

  5. #5
    Registered User
    Join Date
    May 2012
    Posts
    5
    i'm using this code Enumerating All Processes

    and the errors are:
    undefined references to 'EnumProcesses@12'
    undefined references to 'EnumProcessModules@16'
    undefined references to 'GetModuleBaseName@16'

    by the way, i'm using code blocks but i try this in visual studio too

  6. #6

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Did you link to the correct library?
    Google implies the correct library is "psapi" for the first "undefined reference".

    Newbie NOTE: A header file is NOT a library and is used in the compiling stage NOT the linking stage.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    note : you want psapi.lib in your linker command, not psapi.dll to get the link to work. the dll is needed at runtime and will already be in the proper location on your system (\windows\system32).

    Kernel32.lib on Windows 7 and Windows Server 2008 R2;
    Psapi.lib if PSAPI_VERSION=1 on Windows 7 and Windows Server 2008 R2;
    Psapi.lib on Windows Server 2008, Windows Vista, Windows Server 2003, and Windows X

  9. #9
    Registered User
    Join Date
    May 2012
    Posts
    5
    tanx for your answer

    yes, you are right. i find out the problem and god willing solved it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't find what '->' is used for.
    By Mark Labarbara in forum C Programming
    Replies: 8
    Last Post: 01-01-2012, 09:51 PM
  2. Can't find where the value changes
    By nirvana619 in forum C Programming
    Replies: 4
    Last Post: 08-10-2010, 12:22 PM
  3. std::string::find vs std::find
    By petry in forum C++ Programming
    Replies: 17
    Last Post: 07-08-2009, 05:26 PM
  4. help me find out why it is like this
    By Masterx in forum C++ Programming
    Replies: 26
    Last Post: 01-23-2009, 12:05 PM
  5. gcc can't find gtk.h
    By silk.odyssey in forum Linux Programming
    Replies: 9
    Last Post: 07-05-2004, 03:02 PM