I have one service, if it stopped normally by either stopping it thro SCM applet or user manually shutting down the system i am doing all the processing before it shuts down in Service Control handler function when it receives SERVICE_CONTROL_STOP or SERVICE_CONTROL_SHUTDOWN messages.
But I need to handle when this service is killed/stopped abruptly thro task manager or thro some other means. what message does it send to Control handler function so that i can do something here ,
I've got a little snippet I wanna use to do a splash screen from a mask-image (2-bit image). well... it doesn't work
CBitmap bg_Image; // create Image
bg_Image.LoadBitmap(IDB_BITMAP1); // load from resource
bg_Image.GetBitmap(&bBitmap); // load bitmap data
BYTE *pBuffer = new BYTE[bBitmap.bmWidth * bBitmap.bmHeight];
CRgn newRegion; // new region for dialog
newRegion.CreateRectRgn(0,0,0,0); // creat empty region
CRgn tmpRgn; // temporary region
for (int y=1; y< bBitmap.bmHeight; ++y)
for (int x=1; x < bBitmap.bmWidth; ++x)
BYTE c = pBuffer[(y)*bBitmap.bmWidth + x];
if (c == 255) // white
tmpRgn.DeleteObject(); // clear out region
newRegion.CombineRgn(&newRegion, &tmpRgn, RGN_OR);
delete  pBuffer;
The result is nothing near what I expected... some ragged & jagged dialog.
when I set a breakpoint on "tmpRgn.CreateRectRgn(x,y,x+1,y+1);"
I find that the x and y of the for-loop is not what it should be in the image!!!
any hints on how to do my splash-screen?
so for anybody who's intrested and for the sake of completeness:
// Symbol für dieses Dialogfeld festlegen. Wird automatisch erledigt
// wenn das Hauptfenster der Anwendung kein Dialogfeld ist
SetIcon(m_hIcon, TRUE); // Großes Symbol verwenden
SetIcon(m_hIcon, FALSE); // Kleines Symbol verwenden
// TODO: Hier zusätzliche Initialisierung einfügen
CBitmap bg_Image; // Bild erstellen
bg_Image.LoadBitmap(IDB_BITMAP1); // Bild aus Resource laden
BITMAP bBitmap; // Damit man auf die Daten des Bitmap zugreifen kann
bg_Image.GetBitmap(&bBitmap); // Daten reinladen aus dem CBitmap
int iByteSize = bBitmap.bmWidthBytes * bBitmap.bmHeight * (bBitmap.bmBitsPixel/8);
BYTE *pBuffer = new BYTE[iByteSize];
CRgn newRgn; // Eine neue Region für den Dialog
CRgn tmpRgn; // Eine Temporäre Region
int iOffset = bBitmap.bmBitsPixel/8;
for (int y=0; y< bBitmap.bmHeight; ++y)
for (int x=0; x < bBitmap.bmWidth; ++x)
c = y*bBitmap.bmWidthBytes + x*iOffset;
r = pBuffer[c+2];
g = pBuffer[c+1];
b = pBuffer[c];
if (r == 255 && g == 255 && b == 255) // weiß
tmpRgn.DeleteObject(); // Die Region erstmal leer machen
newRgn.CombineRgn(&newRgn, &tmpRgn, RGN_OR);
delete  pBuffer;
return TRUE; // Geben Sie TRUE zurück, außer ein Steuerelement soll den Fokus erhalten
I'm having a little trouble writing integer values to a file with ofstream objects. If I do ofstream::write(), then I have to pass it a char or a char*. So far, in my code, I've tried doing the following:
const int numOrds = 10;
Basically, since I know the array is a contiguous memory location of 10 integers, I do a write starting from the pointer value of ordX and ordY through sizeof(int) (4) * numOrds (10) = 40 bytes. What I expect is to have 20 4-byte integers lined up in my file one after another. Unfortunately, when I read back from the file, I'm not getting the right result. Any ideas?
I guess I should also specify how I'm reading back the file using an ifstream object.
ifstream geomFile("C:\\geom.dat", ios::binary);
for (int i = 0; i < 10; i++)
ordX[i] = *(int*)readBuf;
I know the above looks a bit like a hack, but I'm sort of confused as to how I'd manipulate things in 4-byte blocks other than casting to int* and dereferencing.
I'm pretty sure this will write the characters to file in ASCII, won't it? I was trying to write it as binary. The thing is, I'm trying to do a minimalist database design, so writing out the x and y ordinates of 13945 and 19053 as ASCII would take 10 bytes, whereas as a 32-bit int, would only take 8 bytes.
The software I am coding uses AfxThrowArchiveException(CArchive::none) to undo changes made by partially loading a document into the program. However, another afx message stating "Failed to open document." pops up and the operator has to again click OK on the dialog. Is there anyway to override this second message box from popping up?
I know there are numerous articles on this topic, but I haven't found a solution to my problem.
From my GUI app I launch a stub process which is supposed to give me real time feedback on the output of a third console. Basically I set up the pipes and handles from the GUI, launch the stub which inturn modifies it's screen buffer and launches the real console. All the handles are inherited correctly, until I modify the memory of the real console.
I coded the stub to start the new process with the CREATE_SUSPENDED flag set, it also returns the ID's back to the GUI. From there I modify the memory and call ResumeThread(). But, for some reason, the STD_OUTPUT_HANDLE which it should have inherited from the stub has been lost. I have verified that the real console is indeed running, though it has no 'visible' screen buffer to output it's contents to.
Through inheritance, I do get the screen contents, but not in real time and without any of the modifications that the stub was supposed to perform.
Any ideas as to how or why this might have happened? Is there any way I can reset the std_output handle after a call to CreateProcess() ?