|
If statement contains more than one statement. You will have to use curly bracket.
#include
int main()
{
int one = 3, two = 4;
if (one < two)
{
two = one;
cout << "successful change\n";
}
else
cout << "failed..\n";
return 0;
}
Manish
|
|
|
|
|
its a test someone gave me, I was supposed to make a code that would make a bigger number into the smaller number... silly thing..
|
|
|
|
|
thanks guys, you solved the problom
|
|
|
|
|
Hi my program will create some text files at runtime. this should not be edited by the user. what i have to do?
|
|
|
|
|
SetFileAttributes( FileName, attrib)
|
|
|
|
|
saisp wrote: Hi my program will create some text files at runtime. this should not be edited by the user. what i have to do?
Probably the above has nothing to do with the title of you post.
If you don't want to allow access to your files, then create those files without allowing sharing. If you really need to make the files hidden, then use FILE_ATTRIBUTE_HIDDEN in the creation flags.
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.
|
|
|
|
|
Please Clear Whether created file is not edited at runtime by user.
If yes, Create it in exclusive mode.
Manish Rastogi
|
|
|
|
|
user should not delete or edit those files at any time.
|
|
|
|
|
It sounds like you need to deny access via an ACL. Simply hiding the file or making it read-only is easily thwarted.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I too have a same issue . . . didnt find a solution yet
Proud To Be an Indian
|
|
|
|
|
Hi All,
I like to enumerate printer jobs, but EnumJobs return correct information about jobs on local printer, but it always returns 0 for Number of jobs (the last parameter of EnumJobs 'LPDWORD pcReturned') when I call it for network printers.
Thanks!
|
|
|
|
|
How about the GetPrinter() function with level 2?
|
|
|
|
|
Tried GetPrinter with PRINTER_INFO_2, but cJobs of PRINTER_INFO_2 returns 0.
Thanks!
|
|
|
|
|
Try specifying some access parameters in the OpenDriver() Function.
|
|
|
|
|
Hi ...
I'm using namedpipe for my interprocess communication.
For each client that requires communication will have a separate instance of the namedpipe.
My question is: is there an API that I could use to get the number of active instances of a namedpipe?
I need this so that when my process ends it will wait first for the nedpipe server to disconnect before exiting my process.
Thanks in advance ...
|
|
|
|
|
Maybe GetNamedPipeHandleState() using the lpCurInstances parameter.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hi mark,
thanks for the suggestion.
however, i tried searching it in the net and couldn't find any sample implementation that uses the GetNamedPipeHandleState API.
I also tried coding like this:
DWORD dwCurIntances;
DWORD dwState;
dwCurIntances = 0;
dwState = 0;
while ( TRUE )
{
// Wait for all the namedpipe instances to close first
if( !GetNamedPipeHandleState( (HANDLE) hClientReqPipe, &dwState, &dwCurIntances, NULL, NULL, NULL, 0 ) )
{
dwResult = GetLastError();
strLog.Format( "@@@@@@@@@@@@@@@@@@@@ GetNamedPipeHandleState Error: %d.", dwResult );
fnAddToMessageLog( 0, strLog );
break;
}
if ( dwCurIntances == 0 )
{
strLog.Format( "@@@@@@@@@@@@@@@@@@@@ All namedpipe instances have been closed." );
fnAddToMessageLog( 0, strLog );
break;
}
}
but I think it does not go the way I expected it.
I'm expecting that the value of dwCurIntances during the startup is "1", since I have created the namedpipe once only. the value I get is "7".
would appreciate your help.
thank you.
|
|
|
|
|
Hmm I'm not sure how you're getting 7.
I tried your code after a single CreateNamedPipe() call and got 1, as expected.
The instance count should remain equal to the number of CreateNamedPipe() calls you've made
for a given name until you've closed the handle to the pipe instance.
This may not be useful to you.
What do you need to wait for before exiting your process ? Are you waiting for all clients
to disconnect?
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I need to wait for all the namedpipe instance to be disconnected by the server first before my process exit.
I tried again the code, I already getting "1" for the instance count.
If the server already called the DisconnectNamedPipe(), shouldn't be the number of instance decreased?
thanks again
-- modified at 10:09 Tuesday 26th June, 2007
|
|
|
|
|
how to disable collapsing a tree item? using CTreeCtrl, thanks!
|
|
|
|
|
Handle the TVN_ITEMEXPANDING notification and set *pResult = 1;
|
|
|
|
|
hi, thanks but i meant the user should not be able to COLLAPSE the item, i changed the double click and keydown event, it works!
|
|
|
|
|
void AceAuditMainDialog::OnTvnKeydownMainTree(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<lpnmtvkeydown>(pNMHDR);
// TODO: Add your control notification handler code here
if ( pTVKeyDown->wVKey == VK_LEFT )
{
// ???
}
*pResult = 0;
}
what should i do inside the if? i want the program do nothing, not to collapse the tree item
|
|
|
|
|
I dont suggest you to handle the key down event to prevent the item from collapsing. As i previously said, overide the TVN_ITEMEXPANDING and handle the collapsing there
void MYDlg::OnItemexpandingTree1(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;<br />
if( items is already expanded)<br />
{<br />
*pResult = 1;<br />
}<br />
else<br />
{<br />
*pResult = 0;<br />
}<br />
}
|
|
|
|
|
nathan7 wrote: but i meant the user should not be able to COLLAPSE the item
Thats what I meant also. If you set that value as 1, that nodes will no longer able to collapse.
nathan7 wrote: i changed the double click and keydown event, it works!
What all keys you handled? Did u try pressing -( minus ) in the node?I doubt there are more keys like this. So you have to handle all that..
|
|
|
|