|
MSDN Search:
HOWTO: Enumerate Applications in Win32
Q175030
The information in this article applies to:
Microsoft Win32 Application Programming Interface (API), used with:
the operating system: Microsoft Windows NT, version 4.0
Microsoft Windows 95
the operating system: Microsoft Windows 2000
Definitely one of the best starting points to do it.
|
|
|
|
|
Use CreateToolhelp32Snapshot, Process32First and Process32Next defined in tlhelp32.h. It works on Win9x as well as NT (PSAPI gives you more control, but only works on NT).
/moliate
|
|
|
|
|
Actually, ToolHelp32 funtions are *not* available on NT4, according to MSDN. W2K supports them, however.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Sorry, my mistake...
Thanks for the info.
/moliate
|
|
|
|
|
Thanks folks! (Yes I'm a bit late, just didn# get notifs)
I went with the ToolHelp23 functions, since Win98 and W2K are enough and NT4 isn't *that* important.
Peter
|
|
|
|
|
I'm writing an application that opens bitmaps and then let user make a
selection by drawing a dragging rectangle with mouse. I'd like that drawn
rectangle does not disappear on mouse-left-button-up event, but only on next
button-down event.
Someone could tell me how this code doesn't work? Or may suggest me some
right code, please?
// m_bDrag, m_bDraw, m_bEraseRect are boolean initally set as FALSE by
constructor
void CFotoView::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
m_bDrag = TRUE;
CClientDC dc(this);
if(m_bEraseRect)
{
dc.SetROP2(R2_NOTXORPEN);
dc.Rectangle(m_ptFirst.x, m_ptFirst.y, m_ptLast.x, m_ptLast.y);
m_bEraseRect = FALSE;
}
m_ptFirst = point;
CScrollView::OnLButtonDown(nFlags, point);
}
void CFotoView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDrag)
{
if(nFlags)
{
m_bDraw = TRUE;
m_ptCurrent = m_ptNew = point;
//ClientToScreen(&m_ptCurrent);
//ClientToScreen(&m_ptNew);
m_bDrag = FALSE;
}
}
else if(m_bDraw)
{
CClientDC dc(this);
dc.SetROP2(R2_NOTXORPEN);
dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
m_ptNew = point;
//ClientToScreen(&m_ptNew);
dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
}
CScrollView::OnMouseMove(nFlags, point);
}
void CFotoView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_bDraw)
{
CClientDC dc(this);
m_bDrag = FALSE;
m_bDraw = FALSE;
ReleaseCapture();
dc.SetROP2(R2_NOTXORPEN);
//ClientToScreen(&point);
//dc.Rectangle(m_ptCurrent.x, m_ptCurrent.y, m_ptNew.x, m_ptNew.y);
m_bEraseRect = TRUE;
m_ptLast = point;
}
else if(m_bDrag)
{
m_bDraw = FALSE;
m_bDrag = FALSE;
ReleaseCapture();
}
CScrollView::OnLButtonUp(nFlags, point);
}
Thanks everyone could help me.
Bye
giampy
|
|
|
|
|
you are probably overwriting the rectangle in your OnDraw call. in general, you should try to handle all drawing from your OnDraw. every other function should just Invalidate the parts of the view that it wants redrawn. there are execptions to this rule, of course; but this is a good way to start.
-c
POKE 808,234
|
|
|
|
|
YOU'RE RIGHT!!!
I followed your precious hint and now it works!
Thx: this really helped me!
giampy
|
|
|
|
|
If you haven't looked at it already, take a look at the CRectTracker class. The documentation suggests that it's intended for OLE/COM, but in reality it's much more general than that and makes it pretty easy to do what you describe wanting.
|
|
|
|
|
Hi, All!
=======
Is there any way for me to create an operator.
For example, like the 'new' operator:
Instead of: x= new int[5];
It will be: x= MyNew int[5];
NOT : x= MyNew(sizeof(int)*5) ;
BTW: come to #CodeProject on DalNet (mIRC)
|
|
|
|
|
do a google search on "override operator new". i got 4900 hits. at least the first three pages all looked relevant.
-c
POKE 808,234
|
|
|
|
|
Look up operator new on MSDN.
Michael
|
|
|
|
|
|
I have a program where I need to replace the Alphabet value to numers.
Examples:
I have B13 which has to be replace with 1013.
10 is just aplhabet count. I would know the position in the string to replace.
Please help me.
|
|
|
|
|
But "B" isn't the 10th letter.
Describe your problem more.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If you count the alphabet A-woud be 10, B- 20,
C-30 ....Z-26
So I have a string where mixed value:letters and numbers.
I need to replace the value of letter with applicable numbers. The string len is different every time.
Thanks.
I tryed your code with my string Modifier and it's not working. Can you tell me why?:
for (i=0; i < strlen(Modifier); i++)
{
ch = Modifier.GetAt(i);
switch (ch)
{
case 'A':
str.Delete(i);
str.Insert(i,"10");
break;
case 'B':
str.Delete(i);
str.Insert(i,"20");
}
}
|
|
|
|
|
A is 01, not 10. Otherwise, A and J have the same value.
Having said that, I would do this by building a second string, otherwise it gets too messy, because you're inserting two chars in the place of one and need to track that in terms of GetAt(). For example if I have "ABC" and I GetAt(0) and replace it, I end up with the string "01BC". If I then iterate through the loop I GetAt(1), I will get back '1', NOT 'B'.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I think he wants to replace all letters in a string with two-character numeric representations.
Assuming a CString is being used:
#include <ctype.h>
CString sText = "A big lazy dog";
CString sResult = "";
CString sTemp = "";
int nLen = sText.GetLength();
sText.MakeUpper();
for (int i = 0; i < nLen; i++)
{
char cCurr = sText.GetAt(i);
if (isalpha(cCurr))
{
sTemp.Format("%02d", (int)cCurr - 64);
sResult += sTemp;
}
else
{
sResult += CString(cCurr);
}
}
<pre>
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
another "funny" story noone knows to help me - see my mail to rational user-board (hi...)
i got many recommendations:
they speak it is not ccase problem only - i never mentioned it at "normal" disc - do you?
it is ntfs problem - i have fat32
use cc-view at your machine - already is, allways was
try patches and service packs - i have them (i hope good ones): w2000 with sp2, msdev 6.0 with c++ processor pack and service pack 4(a) (by my info sp5 has to have another problems)
do you have any ideas?
thanks
t!
hi
one of similar situations
cc4.1 multisite, patches 13-17, dynamic view stored on w2000 client, nt4 server with vob replicas
msdev (6.0, service pack 4, processor pack) project stored on dynamic view contains view-private or checked-out file
config spec: element * checkedout, element * \main\latest
1. in msdev editor edit the file (programming source)
2. save it
3. hands up for 5 minutes - not necessary execute step 3.
4. run msdev compiler - it creates .obj (view private) .exe/.dll (again not under source control), and few other output files, no omake/winkin/etc. is used
5. hands up for 5 minutes - not necessary execute step 5.
6. try run msdev debugger
-> now (sometimes, not everytime, more often with w2000 than nt4) displays for me absolutely nonsence msdev message about "file was modified outside editor, reload it?"
(view private file, one view user, seems long time no another-user change into file's directory, ...)
are we alone with this situation? what to do with?
thanks
t!
|
|
|
|
|
When I use the open file for outputr function like this:
Open "c:\test.txt" For Output As #1 my program works great.
Now I wan't to make "c:\test.txt" to be \\rww2k001\algemeen\test.txt. When the rww2k001 server is online everything works great, but when I disconnected from the server Visual Basic crashes. Does someone know how error handling or something else works with this function.
|
|
|
|
|
shouldn't this be something like ON ERROR GOTO ??
(admittedly, my VB knowledge is limited to witty remarks... ;~) )
peter
|
|
|
|
|
- I want to test what is the max memory space that I can allocate. (If I allocate more space than that, the machine will be halted or error will occur.)
- Can you show me sample codes about that task?
- Regards,
Maer
|
|
|
|
|
The closest thing to what you want is to use GlobalMemoryStatus[Ex]. Note that in multitasking system the available memory can (and probably will) change between the call to GlobalMemoryStatus and actual allocation - so don't count on reliability of this technique.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
- Thanks, Sowinski pal!
- Your reply helps a lot. I still have a question. In MSDN (Ti: GlobalMemoryStatus), it is said, "The information returned by the GlobalMemoryStatus function is volatile.".
I am a newbie of this field. I do not know what means "volatile". Can you show me an example?
- Regards,
Maer
|
|
|
|
|
What 'volatile' implies is that the info returned by GlobalMemoryStatus cannot be guaranteed to be correct. You can try this by making successive calls and putting a Sleep(500) in between. You can be sure that you'll get different information. This is because by the time you get the info the memory status of the system would have changed.
Nish
Sonork ID 100.9786 voidmain
|
|
|
|