|
your file is being included more than once, so it's trying to create the enum more than once ( I reckon ). If you're using precompiled headers ( stdafx.h ), try including it in there and nowhere else in your project. The other thing is to put an inclusion guard block around your code so it will only include once. I think #pragma once is all you need to do this, at the top of the file.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I need to close IE after starting IE with Createprocess. I am using ::PostMessage to try to close IE, but it is not working. I want to use Createprocess to start IE.
LPSTR szAPP = "c:\\progra~1\\intern~1\\iexplore.exe";
(CreateProcess(NULL,szAPP, NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo));
Sleep(10000);
hWnd=FindWindow(_T("IEFrame"), NULL);
::PostMessage(hWnd, WM_CLOSE, NULL, NULL);
|
|
|
|
|
Why dont u use ExitProcess API to close it.
"I would luv to change the world, but they wont give me the source code"
My Articles
|
|
|
|
|
ZakAkili wrote:
hWnd=FindWindow(_T("IEFrame"), NULL);
Hi Mr Zak,
have you check for returned hWnd , may be it's NULL?
ZakAkili wrote:
::PostMessage(hWnd, WM_CLOSE, NULL, NULL);
Try WM_QUIT or pass ProcessInfo.hProcess returned from CreateProcess to TerminateProcess to closedown the IE
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Try:
LPCSTR szAPP = "c:\\progra~1\\intern~1\\iexplore.exe";
CreateProcess(NULL,szAPP,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo));
Sleep(10000);
TerminateProcess(ProcessInfo.hProcess, 0);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks, All of the replys have helped.
|
|
|
|
|
Hi Guys.
I was reading through one of Mike's articles on sockets. And I just CANT
seems to wrap my brain around this one:
BYTE* bp = (BYTE*)(&dataLength) + sizeof(dataLength) - cbLeftToReceive;
I got this far:
(Its a Byte)(Called bp) = (Point to Byte)(&WHAT?!?!) + Something?
Okay now I'm lost.. I simply dont get the (&dataLength), now Datalength
is just an int, so what with the (&int) what does it do?
What does the syntax here mean?
Somebody please help me out!
Shine
|
|
|
|
|
Mike who?
Which article?
Shining2005 wrote:
BYTE* bp = (BYTE*)(&dataLength) + sizeof(dataLength) - cbLeftToReceive;
BYTE* bp ==> bp is a pointer to a BYTE
(BYTE*)(&dataLength) ==> casting the address of dataLength to a BYTE pointer
+ sizeof(dataLength) ==> advance the BYTE pointer to the byte just past the end of the memory occupied by datalength
- cbLeftToReceive; ==> bring the pointer back cbLeftToReceive bytes
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hello gurus,
I'd like to know how I can convert a DWORD (32 bits) value into a byte array of four bytes (32 bits)?
<br />
DWORD dwLength=(DWORD) file.GetLength();<br />
BYTE length[4];<br />
length contains the value dwLength as a 4 bytes array.
Thanks
Best regards.
There is no spoon.
|
|
|
|
|
for (int i = 3; i >= 0; --i)
{
length[3 - i] = (dwLength & (0xff << (i * 8))) >> (i * 8);
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
DWORD dwLength=(DWORD) file.GetLength();
BYTE length[sizeof(DWORD)];
*(DWORD*) &length[0] = dwLength; Keep in mind that any code doing anything with the bytes will have to account for the endian type of the CPU.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hi,
Thanks
Actually I've found the following way:
<br />
length[0]=HIBYTE(HIWORD(dwLength));<br />
length[1]=LOBYTE(HIWORD(dwLength));<br />
length[2]=HIBYTE(LOWORD(dwLength));<br />
length[3]=LOBYTE(LOWORD(dwLength));<br />
which also works
There is no spoon.
|
|
|
|
|
Or how about:
BYTE *pLength = (BYTE*)dwLength;
pLength[0] will equal the low byte (assuming an intel machine)
What do you need this for?
|
|
|
|
|
It works, but not the same way as my code in my earlier post. Yours forces big-endian order. Which isn't wrong per se, it's just something to be aware of. Don't try to write that byte array out to a file and read it back in as a DWORD , for example.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hi
DWORD dwData=0x65A6;
BYTE arrDest[4];<br />
memcpy(arrDest,&dwData,sizeof(DWORD));<br />
|
|
|
|
|
|
Priyank Bolia wrote:
...but not good
Why? This is the method I've used in years past. I find it easier to read than a bunch of pointers ands casts.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I just write that thinking that people like it or not. I still use it in imaging programs, where image documents are large size and memory and speed are a constraint. It saves memory and helps out small programmers from the pointers nightmare, and the main point is it will save precious time as compare to for loops and memcpy operations etc.
http://www.priyank.in/
|
|
|
|
|
hello,
how can I compare two HTML files and know if there text contents has changed and highlight the changed parts.
|
|
|
|
|
google for beyond compare
|
|
|
|
|
I have many shared printers on my windows network. I want to use the API function StartDoc to initialize a print job. How can I get to know the HDC of every printer I have access to. Thank you.
modified 9-Mar-17 17:22pm.
|
|
|
|
|
Hi all,
I'm working on an MFC based application dealing with EN_CHANGE events. In my program, the user has to enter a parameter in a Edit Box, that starts an events:
void CExcitaPage::OnEnChangeAmplitude()
{
//Event...
}
I need to disable this event to configure the program first. Does someone can help me?
NikoiD.
|
|
|
|
|
Are you saying that OnEnChangeAmplitude() is being called when the dialog is first displayed, rather than just when the user makes a change? If so, try:
class CExcitaPage : public CDialog
{
private:
bool m_bInitializing;
};
CExcitaPage::CExcitaPage()
{
m_bInitializing = true;
}
BOOL CExcitaPage::OnInitDialog()
{
CDialog::OnInitDialog();
m_Amplitude.SetWindow(...);
m_bInitializing = false;
return TRUE;
}
void CExcitaPage::OnEnChangeAmplitude()
{
if (! m_bInitializing)
{
}
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Use a flag that is set to false when your app starts and is set to true once your program is configured. Check this flag in the EN_CHANGE handler.
void CExcitaPage::OnEnChangeAmplitude()
{
if (m_bIsPageInitialized)
{
}
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi PJ Arends,
Thank you for your answer! I already tryed our solution, but for a reason that I can't determine, the program crashes because of the declaration of my variable. In the class related to my program's page, I declare as public variable:
<br />
public:<br />
int Configured;<br />
and then I initialize to zero this variable before the configuration. Afterthat I set the variable to one and check in in my handler like that:
<br />
<br />
void CExcitaPage::OnEnChangeAmplitude()<br />
{ <br />
if (Configured) <br />
{ <br />
}<br />
}<br />
When I try to close the program, I become a classic Debug Error, Damage Block...
Do you have an other idea?
Thank you in advance
NikoiD.
|
|
|
|