|
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..
|
|
|
|
|
but if i do as u said, i can't expand the tree
|
|
|
|
|
I have posted the code here[^]. Did you notice that if condition? You can get whether an item is laready expanded or not using the GetItemState() function.
|
|
|
|
|
sorry i didn't see ur code carefully, thanks i understand now~~
|
|
|
|
|
use CTreeCtrl, how to set the font color of a single tree item? other item's font color is not changed
nathan
|
|
|
|
|
You have to handle the NM_CUSTOMDRAW, notification if you want to do this.
|
|
|
|
|
|
I am trying to consume a web service via a dll, I just want to pass in a variable length string that can be up to 5000 characters long, this string is is then passed directy to the web service. I have followed the example in the MSDN on creating a client that consumes a web service http://msdn2.microsoft.com/en-us/library/2k53kft2(VS.80).aspx which works fine but when I change the web service and calling methods to work with a string I get errors, any help on how I should do would be much appreciated.
also Im very new to C++
This is my DLL function that calls the web method.
extern "C" __declspec (dllexport) int __cdecl EMSWSTools(char *lpCmdLine) <br />
<br />
{<br />
using namespace std;<br />
int ret = 0;<br />
<br />
EMSSupTools::CEMSSupTools ws; <br />
<br />
<br />
HRESULT hr = ws.EMSHelper(lpCmdLine, &ret);<br />
if (SUCCEEDED(hr))<br />
return(ret);<br />
else<br />
return(0);<br />
}
|
|
|
|
|
rluckwell wrote: I get errors,
What types of errors are these ?
Add web reference for it again, deleting previous one.
Probably, proxy class and namespace added will be of difference name.
Prasad
MS MVP - VC++
|
|
|
|
|
The error is an AccessViolationException: - Attempted to read or write protected memory. this is often an indication the other memory is corrupt.
I have tried to re add the web reference. I have another web method the just returns an integer which works. I have also setup the test harness in VB that calls the web methods directly and this works fine to.
|
|
|
|
|
Does CFile::Read take a binary file?
|
|
|
|
|
|
Yes. CFile is designed toward binary file access.
It's basically a wrapper for the Windows CreateFile()/ReadFile()/WriteFile()/SetFilePointer()/
CloseHandle()/etc. APIs.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
CFile::Read("test.bin",CFile::modeRead) is the mode to read a binary file? or different flag? Thanks
|
|
|
|