|
The default char type may be unsigned.
This can be controlled by compiler flags.
In that case using 'char' and 'c' works because there is no conversion.
Using 'signed char' and 'c' makes the compiler look for the best conversion from (unsigned char) 'c'. In that case i guess it promotes 'c' to a signed int.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I want to implement Process Communication in visual C. Like if a process is running, i want to write a code which can cause that process to stop or shutdown or a code which detect that a certain process has been start and it should be stopped.
Or can any one give me a good site on IPC to implement the idea above.
Thanks in advance
-oam
|
|
|
|
|
Hi
First of all, call EnumProcess to get all the processes running in the system.
Then call OpenProcess to open the running proccess. You will have got a handle the required Process by now. Set the required access right while opening the process.
Now call TerminateProcess to terminate the process.
Hope this would work for you
Regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
I understand the first paragraph of your comment, but i don't understand if the program will send a message to the running process. I wanted something that will communicate with the running process in many ways.
oam
|
|
|
|
|
Hi
Using of shared memory will of any use to you?
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Hello,
I need to read in all text in a file, How can I do that?.
I need to read in all information direkt.
I have try this;
while(fgets(szLine, 256, filep));
But I only get the first text line.
|
|
|
|
|
Unless I needed to read one line at a time, I would just:
1) Open file for read only.
2) Call _filelength to determine the amount of memory needed.
3) Allocate a buffer large enough to hold it.
4) Call fread, to read the entire text file into the buffer.
5) Close the file.
Now that I have it in a buffer I can do what ever I what with the data.
Thats the simplis way.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
char buffer[HOPEFULLY_BIG_ENOUGH];
int i = 0;
while( !feof(filep))
{
buffer[i] = fgetc(filep);
++i;
}
|
|
|
|
|
Are you kidding? This is the epitome of inefficient. For very small files it would probably suffice, but for files of measureable size, reading from a file one character at a time is a bad design.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Unless you're not using C++, use iostreams instead of C file handling. I have an article on this site about how to do this in C++, I believe.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
And if you are using MFC, try CStdIOFile.
"Aerodynamically, the bumble bee shouldn't be able to fly, but the
bumble bee doesn't know it so it goes on flying anyway." - Mary Kay Ash
My Articles
|
|
|
|
|
Hello,
This may seem rather easy for most of you, but I seem to have difficulty with what should be a very easy task.
I have a Main Frame that opens with a background bmp but no Child. What I want to do is when you click "Start" from the menu, a dialog opens. After filling out a few variables in the dialog, I want to close the dialog, then open two new/different child windows (actually I would like to split the main window into 4 parts and place adifferent child into each quarter).
Can anyone direct me to an online file or tutorial for something like this? I can't seem to find the right reference.
Any help would be GREATLY appreciated!
Thomas (tntnmmd@hotmail.com)
|
|
|
|
|
From the Start Menu ?
Override WM_COMMAND
OnCommand()
{
check ur menu ID, if it from start menu,
CChildDlg oDlg;
oDlg.DoModal();
}
4 Frames???? Sounds like u really need a splitter wnd...
hey refer MSDN , there is no other better source for MFC/SDK..
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
hi,
I would like to know if there is a way by which an application can hook into other applications and access their gui controls (like buttons, textboxes....).
I have done some research on this. I found out that a dll (with SetWindowsHookEx) can be used to hook into the message queue of an application so as to receive all the notifications that are sent to the application. Another method is WH_CBT and CBTProc. But I'm still not clear as to how this can be used to access the internal controls of a windows application.
Thanking you.
|
|
|
|
|
One way would be to send the other application the appropriate message. To "click" a button, try:
SendMessage(hwnd_of_other_app, WM_COMMAND, MAKEWPARAM(button_id, BN_CLICKED), hwnd_of_button);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thank you for replying. SendMessage could help in simulating button clicks. But my problem is how will i know about the button_id ?
The basic assumption is that my application will not know anything about the internal structure of the target application (except for the fact that it is a windows exe). In that case how can i query the control ids ? Is there some generic way that will help to query the ids of the controls ?
Or should i resort to extracting info from the exe file itself ?
Any help will be appreciated.
|
|
|
|
|
Use FindWindowEx() and/or EnumChildWindows() to find the window/control in question. From there you can use GetDlgCtrlID() to get the identifier of the control.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
How to convert a PLBYTE to integer array?
Thx!
|
|
|
|
|
int* makeIntArrayFromByteArrary(LPBYTE *pByte,size_t cbByte)
{
int* pInt = (int*)malloc(cbByte * sizeof(int));
if( pInt ) {
int i;
for( i=0; i<cbByte; ++i )
pInt[i] = pByte[i];
}
return pInt;
}
int* makeIntArrayFromByteArrary(LPBYTE *pByte,size_t cbByte)
{
int* pInt = new int[cbByte];
if( pInt ) {
for( int i=0; i<cbByte; ++i )
pInt[i] = int(pByte[i]);
}
return pInt;
} Do not forget, you are responsible for freeing memory after you are finished using the allocated arrary of intergers.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Maybe it is really a newbie problem, but how to obtain the size of *pByte? just use sizeof operator?
|
|
|
|
|
samhwang wrote:
...how to obtain the size of *pByte? just use sizeof operator?
Pointers have a constant size of 4 bytes. Perhaps you are wanting to know how many bytes the pointer is pointing to.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sorry, I've been away!
1) "PLBYTE" is not a defined type it should be "LPBYTE" or "BYTE*".
2) I made a mistake: "LPBYTE *pByte" should be "LPBYTE pByte" or "BYTE* pByte".
sizeof examples:
BYTE b;
int i;
BYTE ba[10];
int ia[10];
BYTE* pba = ba;
int* pia = ia;
//sizeof(b) = sizeof(BYTE) = 1
//sizeof(i) = sizeof(int) = 4 (on 32-bit compilers)
//sizeof(ba) = 10*sizeof(ba[0] = 10*sizeof(BYTE) = 10
//sizeof(ia) = 10*sizeof(ia[0] = 10*sizeof(int) = 10*4 (on 32-bit compilers)
//sizeof(pba) = sizeof(BYTE*) = 4 (on 32-bit compilers)
//sizeof(pia) = sizeof(BYTE*) = 4 (on 32-bit compilers)
Notes:
1) sizeof(int) is the size of a machine word.
2) A machine word is the maximum number of bytes that can fit into one machine register.
3) Reality: What the size of an int is depends on the compiler you are using;
16-bit -> sizeof(int) = 2,
32-bit -> sizeof(int) = 4,
64-bit -> sizeof(int) = 8.
Well, I hope that answers all your questions.
Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Can someone upload amstream.h somewhere? Visual Studio 2005 doesn't have it...
|
|
|
|
|
*sigh* What do you expect to do with a single header file ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Why does this program crush?, what have i left?
<br />
#include "stdio.h"<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{ <br />
FILE* fp;<br />
char fname[10];<br />
<br />
printf("Enter the file name: ",fname);<br />
scanf ("%s",fname);<br />
<br />
if( fp )<br />
fopen("&fname","wt");<br />
{ <br />
int i;<br />
for( i=0; i<10; ++i ) <br />
fprintf(fp,"Line %d\n",i); <br />
<br />
fclose(fp); <br />
} <br />
return 0;<br />
}
oam
|
|
|
|