Hello!
I'd like to use QSharedMemory for changing data between processes.
In first process - something about:
QSharedMemory m_Pool;
m_Pool.setKey("POOL");
if (!m_Pool.create(128))
{
//some error message
}
QSharedMemory m_Pool;
m_Pool.setKey("POOL");
if (!m_Pool.create(128))
{
//some error message
}
To copy to clipboard, switch view to plain text mode
m_Pool.lock();
char *pBuffer = static_cast<char*>(m_Pool.data());
strcpy(pBuffer, "some data");
m_Pool.unlock();
m_Pool.lock();
char *pBuffer = static_cast<char*>(m_Pool.data());
strcpy(pBuffer, "some data");
m_Pool.unlock();
To copy to clipboard, switch view to plain text mode
In second process:
char *p_buffer = NULL;
QSharedMemory smPool("POOL");
if(!smPool.attach(QSharedMemory::ReadOnly)){
// some error message
}
smPool.lock();
char *pBuffer = static_cast<char*>(smPool.data());
p_buffer = strdup(static_cast<char *>(pBuffer));
smPool.unlock();
char *p_buffer = NULL;
QSharedMemory smPool("POOL");
if(!smPool.attach(QSharedMemory::ReadOnly)){
// some error message
}
smPool.lock();
char *pBuffer = static_cast<char*>(smPool.data());
p_buffer = strdup(static_cast<char *>(pBuffer));
smPool.unlock();
To copy to clipboard, switch view to plain text mode
It works wonderful until we start both processes from one operating system account. But I need to run the first process from 'admin' and the second process from 'user'. So when I do 'smPool.attach' in second process I get QSharedMemory::PermissionDenied.
More detailed: 'QSharedMemoryPrivate::initKey: unable to set key on lock'.
Is there any opportunity to resolve this problem?
Thanks in advance 
I use WinXP and Win2000.
Bookmarks