|
Batch file is just a text file with a .bat extension in which you can give dos command like del to delete a file.
Create the file through code (CreateFile ) and use CreateProcess to run it.
«_Superman_»
|
|
|
|
|
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
are you trying to close another exe or your exe itself?
You can close your application by Sending WM_CLOSE message to the main window
AfxGetMainWnd()->PostMessage(WM_CLOSE);
or by callnig using PostQuitMessage API
You can kill another process by calling
TermainteProcess[^] API with the process's handle. Remember it's an brutal and unsafe method.
--added--
If you're trying to delete file just call DeleteFile[^] API and pass the path of executable.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
modified on Wednesday, February 11, 2009 4:49 AM
|
|
|
|
|
I think he's trying to physically delete the executable file once it has exited, not trying to stop it while running.
|
|
|
|
|
hmm... I just updated my previous post. Anyway his question is not well clear
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
All possible methods are explained here[^]
|
|
|
|
|
Hello,
I have a handle of a dialog(The dialog lies in another process). Now I want to add a button to that dialog, is it possible ?
Thanks.
|
|
|
|
|
Have a function in your Dialog class that has this :
<br />
CButton* pButton = new CButton;<br />
pButton->Create("NewButton", WS_CHILD | WS_VISIBLE,<br />
CRect(x, y, x1, y1), this, 1234);<br />
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I think I mentioned that the dialog exists in another process.
|
|
|
|
|
You can either do CreateRemoteThread to create a thread in the other process and create the button from that thread.
Or you can write a hook DLL that loads into the remote process and then create the button from the hook procedure.
I don't think you can create a button using the handle of another window or dialog.
«_Superman_»
|
|
|
|
|
Yes, I was thinking that global hooks will be helpful. But can I get some sample code please.
http://www.google.com
|
|
|
|
|
Identity Undisclosed wrote: have a handle of a dialog(The dialog lies in another process). Now I want to add a button to that dialog, is it possible
Can you tell why you need this?
Regards,
Sandip.
|
|
|
|
|
Just for learning purposes
|
|
|
|
|
you learn process manage.
For example: Pipe,Signal,Message,mapped memory,semaphore,Socket
|
|
|
|
|
Resource Hacker[^] is a nice tool where you can permanently modify the resources of executable.
Even if you create the button somehow, you will not be able to manage the messages properly. Anyway Injecting your custom DLL to the other project will help you to some extend....
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Use this project[^] to inject code into the remote process.
The code you inject should create the new button.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi everyone,
I am novelty to Image Processing. Currently, I want to read the data of a monochrome BMP file into an 2D array using VC++ 2005. I read quite a number of articles about BMP file, but there's still a vague explanation concerning the monochrome one.
I know and understand on how to read its header and header information. However, when I read the data of it, the output is 205 for BLACK pixel which makes me very confusing. It should be 0 for Black pixel, right? In short, the followings are my questions:
1. How is data in monochrome BMP file stored?
2. Do I have to read it in RGB order or just one byte a time?
3. Do I have to manage the junk (useless) byte?
Thanks in advance.
Ing LengIeng
Software Developer
|
|
|
|
|
I think a monochomre bitmap is stored as 1 bits per pixel, so 1 byte contains 8 pixels, where every 0 is BLACK and every 1 is WHITE (or whatever you schoose to be foreground and background colors). So if you read 205 -> 11001101 -> WHITE PIXEL, BLACK PIXEL, WHITE, WHITE, BLACK, BLACK, WHITE, WHITE. (don't forget, the leftmost bit is the most significant)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thank you very much!
Ing LengIeng
Software Developer
|
|
|
|
|
You can use bitmasks to gain the pixels out of the bytes, so something like (just to explain and give you a starting point):
SetPixel(x , y, (bmp_byte & 1)?foreColor:backColor);
SetPixel(x + 1, y, (bmp_byte & 2)?foreColor:backColor);
SetPixel(x + 2, y, (bmp_byte & 4)?foreColor:backColor);
SetPixel(x + 3, y, (bmp_byte & 8)?foreColor:backColor);
SetPixel(x + 4, y, (bmp_byte & 16)?foreColor:backColor);
SetPixel(x + 5, y, (bmp_byte & 32)?foreColor:backColor);
SetPixel(x + 6, y, (bmp_byte & 64)?foreColor:backColor);
SetPixel(x + 7, y, (bmp_byte & 128)?foreColor:backColor);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks very much. I gain much understanding now.
Ing LengIeng
Software Developer
|
|
|
|
|
From BITMAPINFOHEADER documentation [^], about biBitCount member equal to 1:
The bitmap is monochrome, and the bmiColors member of BITMAPINFO contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, the pixel is displayed with the color of the first entry in the bmiColors table; if the bit is set, the pixel has the color of the second entry in the table.
Thus one byte of the bitmap array having value 205 represents eight adjacent pixels colors: 11001101 (1-second color of the color table, for instance black, 0-first entry of the color table, for instance white).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Oh! I see. Thank all of you very much for your useful reply.
One more thing! This might be a stupid question, but how can I convert from a Byte into those 8 bits?
Ing LengIeng
Software Developer
|
|
|
|
|
Member 2116736 wrote: but how can I convert from a Byte into those 8 bits?
A byte is already that set of bits.
If you need to extract single bit info you may:
- use the
shift and AND operators:
unsigned int getbit(BYTE byte, int bit){ return ( (byte >> bit) & 0x01; ) }
It may be used as follows:
void main()
BYTE byte = 205;
cout << (int) mb.byte << " decimal is ";
int i=8;
while (i--)
{
cout << getbit(byte, i);
}
cout << " binary " << endl;
} - use the 'union trick', i.e.
struct BitField
{
unsigned int bit0 : 1;
unsigned int bit1 : 1;
unsigned int bit2 : 1;
unsigned int bit3 : 1;
unsigned int bit4 : 1;
unsigned int bit5 : 1;
unsigned int bit6 : 1;
unsigned int bit7 : 1;
};
union MyByte
{
BYTE byte;
BitField bf;
};
That you may use this way:
bool main()
{
MyByte mb;
mb.byte = 205;
cout << (int) mb.byte << " decimal is ";
cout << mb.bf.bit7 << mb.bf.bit6 << mb.bf.bit5 << mb.bf.bit4 << mb.bf.bit3 << mb.bf.bit2 << mb.bf.bit1 << mb.bf.bit0;
cout << " binary " << endl;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks very much, Pallini! Your code is very useful for me.
In case of trouble, I'll come back to you again.
Many thanks,
Ing LengIeng
Software Developer
|
|
|
|