how to create a file shared among all users
-
I used the following code to create a file, so that every user can read, modify, delete and write to it:
CreateFile(
m_szLogFilePath,
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
NULL);but when I log in with a user other than one in which I created the file, I can not save any modification in it neither delete it. any help?
Thank you masters!
-
I used the following code to create a file, so that every user can read, modify, delete and write to it:
CreateFile(
m_szLogFilePath,
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
NULL);but when I log in with a user other than one in which I created the file, I can not save any modification in it neither delete it. any help?
Thank you masters!
I guess your proble is related with the
NULL
value of the fourth parameter, see [^]. :)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 guess your proble is related with the
NULL
value of the fourth parameter, see [^]. :)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]:confused: so what?
Thank you masters!
-
:confused: so what?
Thank you masters!
Provided my guess is correct (I'm not an expert about) you've to explicitely create a security descriptor, see [^]. :)
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 used the following code to create a file, so that every user can read, modify, delete and write to it:
CreateFile(
m_szLogFilePath,
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN,
NULL);but when I log in with a user other than one in which I created the file, I can not save any modification in it neither delete it. any help?
Thank you masters!
Jusef Marzbany wrote:
but when I log in with a user other than one in which I created the file, I can not save any modification in it neither delete it. any help?
What error message are you receiving?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Provided my guess is correct (I'm not an expert about) you've to explicitely create a security descriptor, see [^]. :)
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]You are probably right. If you want to have EVERYONE permission, you need to create new security descriptor. NULL says that the default ACL is used, i.e. only the user or someone with higher privileges (administrator for example) can change the file. Try this: SECURITY_ATTRIBUTES m_pSecAttrib; SECURITY_DESCRIPTOR* m_pSecDesc; m_pSecDesc = (SECURITY_DESCRIPTOR*)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); InitializeSecurityDescriptor(m_pSecDesc, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(m_pSecDesc,TRUE,(PACL)NULL,FALSE)) m_pSecAttrib.nLength = sizeof(SECURITY_ATTRIBUTES); m_pSecAttrib.bInheritHandle = TRUE; m_pSecAttrib.lpSecurityDescriptor = m_pSecDesc; It should create security descriptor with EVERYONE permission. Instead of NULL, send &m_pSecAttrib. Hope I helped.