PDA

View Full Version : QSharedMemory in processes from different accounts



Ursa
3rd March 2009, 12:22
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
}



m_Pool.lock();
char *pBuffer = static_cast<char*>(m_Pool.data());
strcpy(pBuffer, "some data");
m_Pool.unlock();


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();


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.

Ursa
19th March 2009, 08:01
Nobody knows... :( I guess such a restriction really exists. It's a pity. :(

wysota
19th March 2009, 09:50
Maybe you need to configure how the shared memory works on your system. Qt uses native shared memory mechanisms, so you probably have to look for a solution on some WinXP related sites.