Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CALLBACK .. URGENT .... PLEASE

Posted on 1999-06-24
18
Medium Priority
?
344 Views
Last Modified: 2010-04-02
Hi... In the microsoft website, has an example of List Process in Memory...
But this example, use CALLBACK... I don't know use this...

The Microsoft Example:
http://support.microsoft.com/support/kb/articles/Q175/0/30.asp

I need only show the EXE file name's in a MessageBox() only... using this microsoft example...

Excuse me for my bad english
Thanks
0
Comment
Question by:sennaspy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 3
  • +1
18 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1198384
CALLBACK is no big deal.  It is a #define that is used to define standard attributes for a windows callback function.  basically it is something like

#define CALLBACK _cdecl

And you would use it before a function defintion like

int CALLBACK f(int *IPtr);

something like that.  You should use it before any function you declare that will be used as a windows callback function, for example if you were to write a procedure to be called by theEnumProcs() procedure in the example, you would declare it like

BOOL CALLBACK YourProcedure(DWORD, WORD, LPSTR,  LPARAM )
{
};

Let me know if you have any questions.
0
 
LVL 3

Author Comment

by:sennaspy
ID: 1198385
Ok.. thanks...
But... Looking this:

http://support.microsoft.com/support/kb/articles/Q175/0/30.asp 

I need show the EXE file name's in a MessageBox() only... using this microsoft example...
Please... thanks

0
 
LVL 3

Author Comment

by:sennaspy
ID: 1198386
Ok.. thanks...
But... Looking this:

http://support.microsoft.com/support/kb/articles/Q175/0/30.asp 

I need show the EXE file name's in a MessageBox() only... using this microsoft example...
Please... thanks

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:sennaspy
ID: 1198387
Hi...
I need only list the process active in NT and 95/98, if you have other program, but without class or callback, send to me... thanks...

Excuse me for my bad english
0
 
LVL 22

Expert Comment

by:nietod
ID: 1198388
Are you asking how to use the code in the example?

If so, you just need to write a callback function like they show in the example and then call the EnumProcs() function specifying a pointer to that callback procedure.  Then the callback procedure will be called repeatedly.  Each time it is called it will be passed information for a different process.

Your callback procedure would look like

BOOL CALLBACK YourCallbackProc( DWORD dw, WORD w16, LPCSTR lpstr, LPARAM lParam )
{
   // The lpstr parameter points to the EXE's name  Add it to the messagebox.
   return true; // return true to continue enumerating.
}

You would use it like

EnumProc(&YourCallbackProc,NULL);

That's all there is to it.   Let me know if you have any questions.
0
 
LVL 3

Author Comment

by:sennaspy
ID: 1198389
Hi.. Thanks again..
I make this example, but return this message error in line :
" EnumProcs(&YourCallbackProc,NULL); "

[C++ Error] Unit1.cpp(27): E2034 Cannot convert 'int (__stdcall *)(unsigned long,unsigned short,const char *,long)' to 'int (__stdcall *)(unsigned long,unsigned short,char *,long)'.
[C++ Error] Unit1.cpp(27): E2343 Type mismatch in parameter 'lpProc' in call to '__stdcall EnumProcs(int (__stdcall *)(unsigned long,unsigned short,char *,long),long)'.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1198390
Use LPSTR instead of LPCSTR for the 3rd parameter of YourCallbackProc. And

EnumProcs(YourCallbackProc, NULL);
0
 
LVL 22

Expert Comment

by:nietod
ID: 1198391
Actually the change from LPSTR to LPCSTR should be all you need.  The &before the function name in EnumProcs() is optional.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1198392
sennaspy,

Have you solved the problems? You should not have rejected nietod's answer since there is nothing wrong. You may ask him to answer again so that the question can be closed.
0
 
LVL 3

Expert Comment

by:shaig
ID: 1198393
nietod and chensu,
I feel only fair to warn you that this looks like someones homework...

0
 
LVL 22

Expert Comment

by:nietod
ID: 1198394
Homework?  what course?  
0
 
LVL 3

Expert Comment

by:shaig
ID: 1198395
Better ask sennaspy.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1198396
But what evidence do you see that even suggests this?  I have never heard of a course that would have students write OS-specific code, like windows programs, much less a course that would deal with such a non-accademic topic, like obtaining a list of running processes.
0
 
LVL 3

Expert Comment

by:shaig
ID: 1198397
Why using ONLY this example?
Whatever, forget it, it's not such a big issue.

0
 
LVL 3

Author Comment

by:sennaspy
ID: 1198398
Ok... Thanks for all ... I resolved the problem...

But I send points to ... ?!?!?!


0
 
LVL 22

Expert Comment

by:nietod
ID: 1198399
sennaspy, You have to choose the expert that you think helped the most and ask then to submit an answer, then you can grade the answer.

shaig, It is a big issue for me.  I don't like to help people cheat, even by accident.  But I don't think that is the case here.  sennaspy's profile is full of technical questions (and answers) that definitly suggests practical, real-life programming, not accademic programming.
0
 
LVL 3

Author Comment

by:sennaspy
ID: 1198400
Ok...

thanks for all for help...

Nietod, send me again the answer "blank only"... I send point to you..

thanks
0
 
LVL 22

Accepted Solution

by:
nietod earned 600 total points
ID: 1198401
thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question