|
ExitProcess is part of the Win32 API - It's the low level function you call to exit a process. There is a more vicious version called TerminateProcess . exit is a CRT (C Runtime Library) function; every C/C++ compiler will have this function. On Windows it will be implemented in terms on ExitProcess but it will do some "house work" before hand. For example using the CRT function atexit you can register a function to be called when the process exits - If you use ExitProcess you will short-circuit the CRT code which calls them.
My advice would be that if you're not sure of the difference play it safe and use exit .
Steve
|
|
|
|
|
How to create hidden list box?
JAYARAJ
|
|
|
|
|
|
WhiteSky wrote: ShowWindow(0);
prefer using the defined consts:
ShowWindow(SW_HIDE);
it's a question a readability and maintainability...
-- modified at 8:16 Monday 6th March, 2006
|
|
|
|
|
When you create it make sure the WS_VISIBLE style is not set.
Steve
|
|
|
|
|
ShowWindow(GetDlgItem(hdlg,IDC_LIST1),SW_HIDE);
gabby
|
|
|
|
|
I am created a software in asp.net 2005 and i want to create a setup for instalation can any one help me
Mahammadhusen
|
|
|
|
|
I want to change the color of the dialog box in MFC application.
Can you please tell me how can it be possible.
Thanks in advance.
|
|
|
|
|
Use WM_CTLCOLOR (OnCtlColor) or WM_ERASEBKGND
Using OnCtlColor
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
<font color=green>
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
<font color=blue>if</font> (CTLCOLOR_DLG == nCtlColor)<font color=green>
{
hbr = ::GetSysColorBrush(1);
}
<font color=blue>return</font> hbr;
}
Nibu thomas
Software Developer
|
|
|
|
|
Thanks.
It worked fine.
But now I am facing another problem. I want to change the color of the controls like buttons, static as well.
Can you please suggest a way out.
|
|
|
|
|
|
|
OnInitColor is working fine.. thanks
But can you please tell me how can i change the color of the Controls like buttons, static etc?
-- modified at 7:56 Monday 6th March, 2006
|
|
|
|
|
if you want to change color of Buttons
I think first derived class Button
class CMyButton:public CButton
{
then use WM_DRAWITEM
};
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* m_DC = CDC::FromHandle(lpDrawItemStruct->hDC);
...
...
...
}
|
|
|
|
|
place this code below in InitInstance()
SetDialogBkColor(RGB(219,226,242)//set back ground
,RGB(0,0,0));//set foreground
JAYARAJ
|
|
|
|
|
add this function in the OnPaint handler and get amazed....
CPaintDC d(this); // device context for painting
CPen p[64];
int i;
CRect r;
GetClientRect(&r);
for(i=0;i<=63;i++)
p[i].CreatePen(PS_ENDCAP_ROUND,1,RGB(0,(i*2),(i*4)));
for(i=0;i
|
|
|
|
|
I need to write a small automation tool for product testing and we use RS232 for control.
Looking at the serial comms articles here they all seem to need you to scan for received characters rather than having an event and the VC6 sample which has an event uses the MSCOMM ActiveX control which can cause some portability problems for me.
Does anyone know of a method which will give events but doesn't rely on ActiveX?
Thanks.
Elaine
The tigress is here
|
|
|
|
|
AFAIK, all serial comms classes are event driven, due to the fact that they are using overlapped IO for the serial port communication. At least for reading the serial port.
Or am I totally wrong here?
|
|
|
|
|
Serial comms is done as a file operation usually, it is sockets that are event driven (AFAIK).
The tigress is here
|
|
|
|
|
See the (much more copmplete) answer from Roger Stoltz.
He says it all.
|
|
|
|
|
Hi Elaine,
I suggest you forget about MsComm32.ocx and write your own class for serial communications.
If you really want an "event" you can use ::WaitCommEvent().
I've written a lot of applications for serial communications all using the same technique:
overlapped I/O, three threads, two message object queues for each port and one callback for received data.
One sending thread, one receiving thread that are spawned from the main thread when the port is opened with a call to ::CreateFile().
The sending thread waits, ::WaitForMultipleObjects(), for a semaphore released with the same amount as message objects added to the send queue.
The receiving thread issues a ::ReadFile() which usually will return FALSE since I use overlapped I/O and ::GetLastError() will return ERROR_IO_PENDING. The receive thread then waits for the event in the OVERLAPPED struct to be signaled.
Having set the comm timeouts properly with ::SetCommTimeouts() the receive event should be signalled after each data package received. How to set the values for the comm timeouts depends on your requirements. Usually I use '1' for ReadIntervalTimeout and '0' for the rest of the parameters.
When the event is signalled, verify the read operation with ::GetOverlappedResult() and you will also get the number of bytes actually read and copied to the buffer you supplied with the call to ::ReadFile(). You could call a callback function from here, or send a windows message or whatever you like for notification, just remember that this is another thread (especially if you use the callback technique).
When you "close" the port, you have to call ::CancelIo() from each thread that has issued a request to the port driver before calling ::CloseHandle().
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Thanks Roger, that is just what I want
Elaine (eternally greatful fluffy tigress)
The tigress is here
|
|
|
|
|
i am trying to made a class which have to drive from 'COleDropTarget'
but on my site installed visual studio does not show this class as base so please tell me what is the reason.
Bankey Khandelwal
Software Engineer
Bankey Khandelwal
Software Engineer
|
|
|
|
|
You can derive from any class you like. The wizard does not show them all, but you should generally avoid using the wizards, and learn to do it yourself
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
So I want to enumerate the processes using NtQuerySystemInformation() native api.
I load it from ntdll.dll
i use the process structure below unlike the one documented by microsoft. but i've seen that others use it too.
typedef struct _SYSTEM_PROCESS_INFORMATION
{
DWORD dNext;
DWORD dThreadCount;
DWORD dReserved01;
DWORD dReserved02;
DWORD dReserved03;
DWORD dReserved04;
DWORD dReserved05;
DWORD dReserved06;
QWORD qCreateTime;
QWORD qUserTime;
QWORD qKernelTime;
UNICODE_STRING usName;
DWORD BasePriority;
DWORD dUniqueProcessId;
DWORD dInheritedFromUniqueProcessId;
DWORD dHandleCount;
DWORD dReserved07;
DWORD dReserved08;
VM_COUNTERS VmCounters;
DWORD dCommitCharge;
SYSTEM_THREAD Threads[1];
} SYSTEM_PROCESS_INFORMATION;
the thing is that when I call it I don't get any error code or null pointers but the structure's members are zeros.
the dNext member is not zero but I can't obtain the next pointer for another system_process_information because i get the invalid pointer error when I try this:
if (ProcessInfo->dNext!=0)
ProcessInfo=(SYSTEM_PROCESS_INFORMATION_DEF *)((ULONG *)ProcessInfo+ProcessInfo->dNext);
And I have another question.
How much space should I allocate for the ProcessInfo structure
i only allocate for one structure
SYSTEM_PROCESS_INFORMATION *ProcessInfo=(SYSTEM_PROCESS_INFORMATION *)malloc(sizeof(SYSTEM_PROCESS_INFORMATION));
or I shouldn't allocate at all. I will obtain a pointer to the structure anyway ?
here is the code I use:
HMODULE ntHinst;
ntHinst=LoadLibraryA(NTDLL);
if (ntHinst==NULL)
{
MessageBoxA(GetDesktopWindow(),"Error loading ntdll\nThe program will now end","ERROR",MB_ICONSTOP);
return 0;
}
_NtQuerySystemInformation=(NTQUERYSYSTEMINFORMATION)GetProcAddress(ntHinst,"NtQuerySystemInformation");
if(!_NtQuerySystemInformation)
{
MessageBoxA(GetDesktopWindow(),"Error obtaining function pointer\nThe program will now terminate","ERROR",MB_ICONSTOP);
return 0;
}
SYSTEM_PROCESS_INFORMATION *ProcessInfo=(SYSTEM_PROCESS_INFORMATION *)malloc(sizeof(SYSTEM_PROCESS_INFORMATION);
if (IsBadReadPtr(ProcessInfo,sizeof(SYSTEM_PROCESS_INFORMATION))||IsBadWritePtr(ProcessInfo,sizeof(SYSTEM_PROCESS_INFORMATION)))
return 0;
_NtQuerySystemInformation(SystemProcessInformation ,(PVOID)ProcessInfo,sizeof(SYSTEM_PROCESS_INFORMATION),&ret);
if (ret==0)
{
MessageBoxA(GetDesktopWindow(),"Function Call Failed: NtQuerySystemInformation\nThe program will now terminate","ERROR",MB_ICONSTOP);
return 0;
}
if(ProcessInfo==NULL)
{
MessageBoxA(GetDesktopWindow(),"Function Call Failed: NtQuerySystemInformation\nThe program will now terminate","ERROR",MB_ICONSTOP);
return 0;
}
while(ProcessInfo!=NULL)
{
//RtlUnicodeStringToOemString(usname,&ProcessInfo->usName,TRUE);
//MessageBoxA(0,usname->Buffer,"",MB_OK);
//RtlFreeOemString(usname);
HANDLE hProc;
hProc=OpenProcess(PROCESS_QUERY_INFORMATION,FALSE,ProcessInfo->dUniqueProcessId);
if (hProc!=NULL)
{
HMODULE hmods[300];
DWORD retv;
char fname[1024];
EnumProcessModules(hProc,hmods,sizeof(hmods),&retv);
retv=retv/sizeof(DWORD);
GetModuleFileNameA(*hmods,fname,sizeof(fname));
MessageBoxA(GetDesktopWindow(),fname,"Process Name",MB_OK);
}
else if (ProcessInfo->dNext!=0)
ProcessInfo=(SYSTEM_PROCESS_INFORMATION_DEF *)((ULONG *)ProcessInfo+ProcessInfo->dNext);
else
ProcessInfo=NULL;
if (ProcessInfo->dNext!=0)
ProcessInfo=(SYSTEM_PROCESS_INFORMATION_DEF *)((ULONG *)ProcessInfo+ProcessInfo->dNext);
else
ProcessInfo=NULL;
}
free(ProcessInfo);
So I get no errors durin calling. but I also get a structure full of zero's.
What is the pb ?
gabby
|
|
|
|