|
Actually you shouldn't use a 32 bit shift on a 32 bit wide number because the compiler is allowed to return you a wrong result:
(from C language specification [^], 6.5.7 Bitwise shift operators, Semantics)
The integer promotions are performed on each of the operands. The type of the result is
that of the promoted left operand. If the value of the right operand is negative or is
greater than or equal to the width of the promoted left operand, the behavior is undefined.
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.
[my articles]
|
|
|
|
|
Hello!
Is there any API that I can use in my application in order to detect at some moment that another application is trying to install a Windows hook (SetWindowsHookEx) ?
Thanks in advance!
|
|
|
|
|
no this is no api to do so. you could create a global api hook for SetWindowsHookEx.
Don't try it, just do it!
|
|
|
|
|
I guess you are refering to WH_DEBUG. I read the documentation for SetWindowsHookEx again and this seems to be the type of hook I was looking for...
modified on Monday, January 21, 2008 10:18:12 AM
|
|
|
|
|
Urgent help required.
Tons of experience yet unable to see where I go wrong with this one.
Got a CPropertySheet in wizard mode.
One of its pages is scanning the serial ports for a device and for this I elected to use a callback method so that this process is kept asynchronously.
Obviously when this page receives the callback it's (possibly/likely) on another thread so I cast one of the callbacks parameter to the instance and post a user defined message to it, like so:
void CCommsPage::NotifyAPC(unsigned nId, bool bResult, void* pParam)<br />
{<br />
CWnd* pThis = reinterpret_cast<cwnd*>(pParam);<br />
<br />
if (pThis > NULL)<br />
{<br />
pThis->PostMessage(WM_NOTIFY_CB, nId, bResult);
}<br />
}</cwnd*>
When this message is processed by the page I am indeed back on the thread that the port scan was initiated from.
Yet when I then get this page to instruct the wizard to progress to the next page, like so:
<br />
CCommsPage::OnCallBackConnect(bool bSuccess)<br />
{<br />
if (bSuccess)<br />
{<br />
...<br />
<br />
#ifdef _DEBUG<br />
CPropertySheet* pSheet = dynamic_cast<cpropertysheet*>(GetParent());<br />
ASSERT(pSheet > NULL);<br />
#else<br />
CPropertySheet* pSheet = static_cast<cpropertysheet*>(GetParent());<br />
#endif<br />
<br />
pSheet->PressButton(PSWIZB_NEXT);<br />
...<br />
}<br />
}</cpropertysheet*></cpropertysheet*>
The wizard boms out completely when CPropertySheet::PressButton() is invoked.
If I replace the call to PressButton() with...
pSheet->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
Then the "Next" button is enabled and when I manually click on that button then the wizard does go on to the next page.
That - however - is not an ideal solution and I really want the wizard to progress programmatically.
I've googled and googled and cannot find any article that has the answers that I look for.
I am sure that someone must have had a similar experience. Either that or I am making such a basic mistake that I should reconsider this career.
Someone please help.
|
|
|
|
|
linton samuel dawson wrote: The wizard boms out completely...
Which means what?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
CPropertySheet returns from DoModal() prematurely.
For the record / to reiterate, obviously more pages are 'queued up' which do show when I replace the PressButton() with SetWizardButtons() and click the "Next" button.
|
|
|
|
|
In the OnCallBackConnect() function, how about sending the parent a user-defined message so that it can "press" its own button?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Simplicity in itself (why didn't I think of this?!)
Anyway, have a cigar on me David. This works a treat!
Still baffled as to why it won't work without this 'workaround' but hey...
|
|
|
|
|
In fact, a user defined message is not required I found.
If instead I use ...
GetParent()->PostMessage(PSM_PRESSBUTTON, PSBTN_NEXT, 0);
where I would previously call CPropertySheet::PressButton() (where GetParent() is of course the property sheet) then this works too.
Could this also be the missing clue? CPropertySheet::PressButton() does exactly what I do now but with a SendMessage() instead.
|
|
|
|
|
You shouldnt work with the same Window in different thread via getting it from the original handle. You better post registered messages to the window handle.
Greetings from Germany
|
|
|
|
|
Ehrm.... I don't use the FromHandle() method and I *am* posting messages like you suggest.
|
|
|
|
|
I'm calling a setup program setup.exe through a bat file. The problem is that although I'm able to execute the setup program the command prompt lies in the background. The intent is to get rid of this prompt; so that if one clicks on install.bat file the installation is shown in the foreground as going smooth without having the window due to running the bat file visible. Note that the bat file is a must as it contains a handful of dos command that has to be executed around the installation. Could there be any other way to package this stuff? Please help.
|
|
|
|
|
Do you control the setup program? If so, is there some reason the DOS commands can't be run from within your Setup program via CreateProcess with SW_HIDE?
Judy
|
|
|
|
|
Yes The bat file controls the running of the setup program.
|
|
|
|
|
tom groezer wrote: Yes The bat file controls the running of the setup program.
That's not quite what I meant when I asked if you controlled the Setup program. Is it your setup program? Did you write it? If that answer is yes, see the second sentence of my previous reply.
"Do you control the setup program? If so, is there some reason the DOS commands can't be run from within your Setup program via CreateProcess with SW_HIDE?"
Judy
|
|
|
|
|
Adding to Judy's reply, check if ShellExecute() would be of any use to you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi All,
I keep getting the infamous "updating source control status" freeze up at random times during the day in Microsoft visual Studio 2005 Professional Edition.
This message keeps coming in the status bar even if I am just navigating through the class view or solution explorer view.
Following solutions haven't worked:
1) In Visual Studio, turn off Tools > Options > Source Control > Plug in
Settings > "Perform background status updates"
2) Create an empty folder c:\vsstemp. Then in Visual Studio, Tools >
Options > Source Control > Plug in Settings > Advanced > Folder for temporary
files - set to "c:\vsstemp" rather than the default location on the network.
3)In the Registry entry for source safe change the AllowStatusUpdates from 1 to 0...but unfortunately it's already 0.
Someone please suggest a solution for this or this a permanent bug ???
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
http://www.codeproject.com/Questions/111260/VS-NET-2008-hangs-everytime-we-load-our-project-fr.aspx?tab=mostrecent
UPDATING SOURCE CONTROL STATUS
YaY! YOU FRIGGIN ROCK! Thank you so much! You dont know how bad this was affecting my work!
Because you helped me so much, I'm gonna return the favor and help those who dont know how to update the hosts file.
We have Visual Source Safe 2006 and Visual Studio 2008.
Our VSS database is on a network drive.
Step 1 - Determine which server\computer the VSS Database is on:
In Visual Studio 2008 select File->Source Control->Change Source Control. Note the "Server Name". You're only interested in the server name which is the value between the beginning back slashes and the next backslash. In my case it is dddmisfile
\\dddmisfile\vssdatabase\FocusDD
Step 2 - Determine the ip address of the server: Open a Command Prompt (start->Run type cmd and press enter) and ping your server name (type ping YOURSERVERNAME in the command prompt box). I typed ping dddmisfile and this is what I got:
c:\>ping dddmisfile
Pinging dddmisfile.azdes.gov [10.104.49.10] with 32 bytes of data:
Reply from 10.104.49.10: bytes=32 time=-52ms TTL=128
Reply from 10.104.49.10: bytes=32 time=-52ms TTL=128
Reply from 10.104.49.10: bytes=32 time<1ms TTL=128
Reply from 10.104.49.10: bytes=32 time<1ms TTL=128
Ping statistics for 10.104.49.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = -52ms, Average = 1073741798ms
The IP Address you are interested in is the one that follows Reply from
In My case its 10.104.49.10
You're also interested in the fully qualified domain name: which is the name of the server with the domain appended to it. In My case its dddmisfile.azdes.gov
Step 3 - Add a line to your hosts file with any text editor Open the file with notepad. Type this in the run box (Start->Run)
C:\WINDOWS\NOTEPAD.EXE C:\WINDOWS\SYSTEM32\DRIVERS\etc\HOSTS
This is what I see before I modify it:
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
To add your server name to this list, simply add a new line and type the ip address then press tab then the fully qualified domain name:
10.104.49.10 dddmisfile.azdes.gov
Thats it! Close Notepad and you're done! Dont even need to reboot!
Dont for get to save your changes!
|
|
|
|
|
Hi all,
Actually, i want to read a ".reg" file and to write it values accordingly in a list control. Now my problem is i m not getting how to read this file. Is there any way to read this file...
|
|
|
|
|
neha.agarwal27 wrote: i m not getting how to read this file.
What is going wrong?
Show your code so far, please. And the errors you get.
A .reg-file is in every respect a normal text-file. It has a certain format. So you would need to write a (medium-complicated) parser.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
CString str;
CStdioFile ptr;
ptr.Open("C:\\Documents and Settings\\Mac01\\My Documents\\web.reg",CFile::modeRead,NULL);
ptr.ReadString(str);
while(str != "")
{
AfxMessageBox(str);
ptr.ReadString(str);
}
ptr.Close();
I am using this code to read my .reg file. It has various values inside it, but output is "ypW".
|
|
|
|
|
What is the third param of CStdIoFile-c'tor?
My MSDN only shows two parameters there: filename and flags.
Other than that, I don't see what is wrong with your code.
This console-program uses std C++ streams instead as MFC, but it works as intended:
#include "stdafx.h"
#undef max //even out some MFC-idiocity
#undef min
#include "iostream"
#include "fstream"
#include "limits"
int _tmain(int argc, _TCHAR* argv[])
{
std::string str;
std::ifstream ptr;
ptr.open("C:\\Documents and Settings\\Mac01\\My Documents\\web.reg");
if( ptr.is_open()) {
std::getline( ptr, str);
while( ptr){
std::cout << str << std::endl;
std::getline( ptr, str);
}
}
else {
std::cout << "Unable to open file!" << std::endl;
}
return ::system( "pause");
} The harder part is interpreting the lines you read.
In '[' and ']' you find the name of the Registry to open, and below that you find key/value-pairs of keys to set.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Your .reg file is most likely in Unicode (UTF-16) format. You have to open the file with the CFile::modeBinary flag.
Also, you may have to create a Unicode project to display the contents of the file properly.
|
|
|
|
|
Michael Schubert wrote: Your .reg file is most likely in Unicode (UTF-16) format.
Such thing is possible?!?
OK, sure. How could it handle non-latin content otherwise?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|