|
[ This ] talks about Shared memory access permissions on Windows.
Maybe [ this ] article on Memory-mapped files might help but it applies to XP, not Vista/Windows 7.
("Memory-mapped files allow a file on disk to be associated with an address space. Once this mapping is done the data in the file can be accessed as if the file was in memory." )
MSDN has lots on Memory-mapped files, google "Sharing Memory Over Networks" and/or "Memory-mapped files".
|
|
|
|
|
|
I am having hard time trying to understand why SetDefaultCommConfig will not set DTR / RTS parameters to 0. I can set the DCB to DTR = DTR_CONTROL_DISABLE (0) but when I read it back using GetDefaultCommConfig it goes back to 1.
I can control baud rate as expected, no problems here.
So what is so special about DTR or RTS that is cannot be controlled using Set/GetDefaultCommConfig?
Has data flow control involved here? In my system it is set to None.
The MSDN is rather cryptic saying that “some parameters cannot be changed” -using these APIs.
Here is my test code snippet:
COMMCONFIG config;
CString sPort;
int nPort = 2;
sPort.Format(_T("COM%d"), nPort);
DWORD dwSize = sizeof(COMMCONFIG);
if (!GetDefaultCommConfig(sPort, &config, &dwSize))
{
TRACE(_T("Failed in call to GetDefaultCommConfig\n"));
}
config.dcb.fDtrControl = DTR_CONTROL_DISABLE;// DTR_CONTROL_ENABLE;
config.dcb.fRtsControl = RTS_CONTROL_DISABLE;
config.dcb.BaudRate = 123456;
config.dcb.fOutxDsrFlow = false;
All parmaters are correct in watch.
if (!SetDefaultCommConfig(sPort, &config, dwSize))
{
TRACE(_T("Failed in call to GetDefaultCommConfig\n"));
}
if (!GetDefaultCommConfig(sPort, &config, &dwSize))
{
TRACE(_T("Failed in call to GetDefaultCommConfig\n"));
}
As always , thanks for your help.
|
|
|
|
|
Vaclav_Sal wrote: some parameters cannot be changed
Maybe it is concise, but is clear: you cannot change some parameters with this function (don't ask me the reason).
If you need to control DTR/RTS then use SetCommConfig every time you need it.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I was hoping to stop the DTR/RTS, set to 0, before I actually need to control them. I wanted to build a different default configuration. I do use SetCommConfig down the line.
And yes, I hope someone will come up with a reason why they cannot be controled by this API. But it appears to be long shot here.
I think I found a workaround, not using DTR/RTS, but I need to test it.
Thanks for your input.
|
|
|
|
|
i have a string such that
hello
hi
good
i want to extract the values line by line....please help
|
|
|
|
|
What sort of string, and what do you mean by extract the values line by line? You could use one of the strtok[^] variants for a simple character array, or one of these functions[^] for a string .
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
i have a character array such thatb char buffer[100];
the values are stored like
cklvcmsdl
dclcm
dcpcc
i have to extract these values line by line and compare them with the input to find matching usernames
buffer contains the usernames
|
|
|
|
|
Well it looks like you need to use the first option I suggested.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
That means the user names are separated by the newline character, you may use strtok as Richard already suggested or hand-craft a simple loop to collect all the names.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As CPallinial suggested, here is simple loop to collect all the names.
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
char one_line_string[] = "hello hi how are you nice weather we are having ok then bye";
char seps[] = " ,\t\n";
char *token;
int main()
{
vector<string> vec_String_Lines;
token = strtok( one_line_string, seps );
cout << "Extracting and storing data in a vector..\n\n\n";
while( token != NULL )
{
vec_String_Lines.push_back(token);
token = strtok( NULL, seps );
}
cout << "Displaying end result in vector line storage..\n\n";
for ( int i = 0; i < vec_String_Lines.size(); ++i)
cout << vec_String_Lines[i] << "\n";
cout << "\n\n\n";
return 0;
}
|
|
|
|
|
Hi all,
I have a program that runs as a service somewhere on a server. It communicates with a console-type program (possibly on another machine within the network) by means of a messages file. The file is created by the service (because there may be multiple console programs running) However, the service is started by an administrator. Due to this, the console programs do not have access rights to the messages file. It works fine if I create the file manually (the service only creates if it does not exist) but if the file for some reason gets deleted, the consoles are no longer able to add their messages into the file.
Is there a way in which I can grant full control rights to all users from the service program after creating the file?
Anyone? Please?
Thanks in advance,
William
|
|
|
|
|
Sorry this doesn't answer your question, but I'd recommend instead you have a network group that has the create and write permissions and then ensure the administrator and other users are members of that group.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Which is indeed what I advised my clients. However, there are several clients using this software and if there is one thing I learned over the years: Sysadmins will ALWAYS have their own thoughts on how to organise and authorize their users!
William
|
|
|
|
|
Ah yes, clients, users and sysadmins. The nemesis of our existence.
It might be possible at the folder level to allow full control to network access and to have that access flow to sub-folders. That might override the local adminstrator account when it creates the file.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Can somebody help in putting 2 tree view in one window in mfc
|
|
|
|
|
You can have two invisible windows as a container each one containing a single tree control. Place both of them in one window.
or write your own owner drawn control...
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
how can i have 2 invisible window under one single window???????
|
|
|
|
|
The main window should contain a CSplitterWnd. The panes of the splitter should contain you CTreeViews.
If you vote me down, my score will only get lower
|
|
|
|
|
How can I close an document from another document ?
Is correct to call simply OnCloseDocument ? :
POSITION posDoc,pos = theApp.GetFirstDocTemplatePosition();
while(pos)
{
CDocTemplate* pDocTemplate = (CDocTemplate*)theApp.GetNextDocTemplate(pos);
posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument* pDoc = pDocTemplate->GetNextDoc(posDoc);
if(pDoc)
{
if(bSomeCondition)pDoc->OnCloseDocument();
}
}
}
|
|
|
|
|
This is unfortunately, not the correct way.
Two possible ways:
If I remember correctly CDocument is a CCmdTarget, you could post a message directly to the document:
pDoc->SendMessage(WM_COMMAND, ID_FILE_CLOSE, 0L);
This may or may not work (untested, unchecked)
Typically a document only has a single view...
As you already have a pointer to the document in question, you can use its GetFirstViewPosition() / GetNextView() functions. You could send a WM_CLOSE to each view.
If you vote me down, my score will only get lower
|
|
|
|
|
In did, I have only a view attached by document, but your code didn't function, I get follow error :
SendMessageA' : is not a member of 'CDocument'
|
|
|
|
|
While i can't tell you how to correctly do this, whenever you see a Windows member function starting with the prefix 'On', then this is an event handler, and should not be called directly. Best case it won't do what you expect, worst case it crashes your app. The purpose of event handlers is to react to events that have already occured, not trigger such an event.
|
|
|
|
|
Well, I turn problem into one simpler, but without solution for me : how is the right way to close an document from CMyApp ? I try in follow way, but I don't know if is correct :
void CMyApp::CloseAllDocuments(CDocument* pDocExcept)
{
POSITION posDoc,pos = GetFirstDocTemplatePosition();
while(pos)
{
CDocTemplate* pDocTemplate = (CDocTemplate*)GetNextDocTemplate(pos);
posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument* pDoc = pDocTemplate->GetNextDoc(posDoc);
if(pDoc != pDocExcept)
{
pDoc->OnCloseDocument();
}
}
}
}
here I want to except for closing down an specific document ...
|
|
|
|
|
I try that in follow way, witout success :
void CMyApp::CloseAllDocuments(CDocument* pDocExcept)
{
POSITION posDoc,posView,pos = GetFirstDocTemplatePosition();
while(pos)
{
CDocTemplate* pDocTemplate = (CDocTemplate*)GetNextDocTemplate(pos);
posDoc = pDocTemplate->GetFirstDocPosition();
while(posDoc)
{
CDocument* pDoc = pDocTemplate->GetNextDoc(posDoc);
if(pDoc != pDocExcept)
{
posView = pDoc->GetFirstViewPosition();
while(posView)
{
CView* pView = pDoc->GetNextView(posView); CFrameWnd* pFrame = pView->GetParentFrame();
pFrame->SendMessage(WM_CLOSE);
}
}
}
}
}
modified 23-Nov-11 2:45am.
|
|
|
|