|
thanks alot for your help Wadi,
Can i ask you any more...
--------------------
Ghazi Al Wadi wrote:
Hi,
Hope this helps
Retrieving the owner of a file requires:
obtain the security descriptor for the file, Use GetFileSecurity()
then using the security descriptor to get a pointer to the owner's Security Identifier (SID). GetSecurityDescriptorOwner()
Finally, you use the owner's SID to obtain the owner and domain name of the file LookupAccountSid()
------------------------
thanks, could you give me a simple example???,
i've tried but it's not resposible:
CString TheFile;
TheFile=CString(Buffer[i].FileName).Left(Buffer[i].FileNameLength / 2);
SECURITY_DESCRIPTOR sd;
DWORD sob;
GetFileSecurity(TheFile,OWNER_SECURITY_INFORMATION,&sd,sizeof(sd),&sob);
SID pOwner;
BOOL OwnerDefault;
GetSecurityDescriptorOwner(&sd,(PSID*)&pOwner,&OwnerDefault);
char AccountName[80];
char DomainName[80];
DWORD cbDomain;
DWORD cbName;
LookupAccountSid(NULL,&pOwner,(LPTSTR)AccountName,&cbName,(LPTSTR)DomainName,&cbDomain,NULL);
::AfxMessageBox(AccountName,0,0);
help me please???!!!
thanks
|
|
|
|
|
Hi,
The issue is you have to find the required buffer for each parameter. see the example below.
Simply open up an MFC Dialog project and place this code in the OnOk () function.
Browse for and select the fpasted file and clikc ok.
Cheers
<br />
void CFindOwnerDlg::OnOK() <br />
{<br />
char szFilters[]=<br />
"MyType Files (*.*)|All Files (*.*)|*.*||";<br />
<br />
CFileDialog fileDlg (TRUE, "*", "*.*",<br />
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);<br />
<br />
if( fileDlg.DoModal ()==IDOK )<br />
{<br />
ULONG uSizeSD ;
PSID pOwner = NULL ;
char szName[MAX_PATH] ;
char szDomain_name[MAX_PATH] ;
<br />
<br />
ULONG uName_len ;
ULONG domain_len;
char *sdBuf;
SID_NAME_USE deUse ;
<br />
<br />
int bSuccess = 0;<br />
szName[0] = 0;<br />
szDomain_name [0] = 0;<br />
uName_len = 0;<br />
domain_len = 0;<br />
<br />
BOOL fOwnerExists = FALSE;<br />
<br />
<br />
<br />
CString pathName = fileDlg.GetFileName ();<br />
<br />
<br />
bSuccess = GetFileSecurity( <br />
pathName, <br />
OWNER_SECURITY_INFORMATION, <br />
0, <br />
0, <br />
&uSizeSD);<br />
if (bSuccess != 0) <br />
MessageBox ("It should not happen as it should be an error "); <br />
else<br />
{<br />
sdBuf = new char [uSizeSD];<br />
<br />
bSuccess = GetFileSecurity( <br />
pathName, <br />
OWNER_SECURITY_INFORMATION, <br />
sdBuf, <br />
uSizeSD, <br />
&uSizeSD);<br />
<br />
bSuccess = GetSecurityDescriptorOwner(sdBuf, &pOwner, &fOwnerExists);<br />
<br />
<br />
bSuccess = LookupAccountSid (NULL , pOwner ,szName, &uName_len, szDomain_name, &domain_len, &deUse);<br />
bSuccess = LookupAccountSid (NULL , pOwner ,szName, &uName_len, szDomain_name, &domain_len, &deUse);<br />
<br />
if (bSuccess == 0) <br />
MessageBox ("Error ");
else<br />
{<br />
CString msg;<br />
msg = szDomain_name ;<br />
msg= msg + "\\";<br />
msg =msg + szName;<br />
MessageBox (msg);<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
}<br />
It is Illogical to define an inventor by his invention
|
|
|
|
|
Hi Ghazi Al Wadi,
You maybe misunderstand my question.
my problem is : When an other computer on my Local Area Network (LAN) connected to my computer and has pasted a file on my Shared Folder. I wanna know : who (which computer on my LAN) has pasted the file?.
Could you help me more, Wadi.
thanks
|
|
|
|
|
Hi Ghazi Al Wadi,
You maybe misunderstand my question.
my problem is : When an other computer on my Local Area Network (LAN) connected to my computer and has pasted a file on my Shared Folder. I wanna know : who (which computer on my LAN) has pasted the file?.
Could you help me more, Wadi.
thanks
|
|
|
|
|
Hi,
yes you are right , I must have misunderstood the question.
The answer assumed that the required piece of information is: "What is the user name of the person who pasted that file on my shared folder" The answer will give you the name of the person who was logged on to the computer that pasted the file. As for from which computer was the files pasted, the answer does not come to me right now.
I would do more invistigation in a timly manner.
I hope one of our fellow CPians may have an answer.
It is Illogical to define an inventor by his invention
|
|
|
|
|
Hi !
I've read somwhere that one of Java's feature is 'reflection', where C++ doesn't have this feature. I tried to find on the web some more info but didn't find anything. What exactly is 'reflection' and is it correct that C++ doesn't have this feature ?
Thanks !
Jerome
|
|
|
|
|
I haven't heard about Java including 'reflection' yet, but I suppose that's a good thing. The first I heard of it was in a book on C#, and I have yet to understand why anyone cares about it. I can't figure out any use for it, any value added in terms of efficiency, readability, or maintainability. Any "improvement" that doesn't add to any of the above is mere clutter, and deserves no attention. As far as I can tell, C++ doesn't have this attribute, and it lacks nothing for its absence.
Some people think of it as a six-pack; I consider it more of a support group.
|
|
|
|
|
Oh..
I think your are wrong. Im new to C# but AFAIK with reflection you can create something like "PlugIns"
with a LOT less code than in C++ ...
|
|
|
|
|
is it somehow related to message reflection in MFC?
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Yes, reflection is a technique that's been in Java for a long time. The Sun page for it can be found here[^]. Basically, it allows you to examine (reflect) a class at runtime and create objects and run functions that you don't know about at compile time. As the API states, you shouldn't use it where something else would be more appropriate, but it can be very useful.
C++ does have some reflection features already - you can use RTTI to examine a class, and there are various techniques for implementing the rest of reflection (policies, STL, etc).
So, it's not correct to say that C++ doesn't have reflection, but some parts of it you need to handle yourself.
|
|
|
|
|
'reflection' is the ability to obtain detailed information about an object type at runtime. You could, for instance, obtain a list of all the method signatures of an object and invoke a method explicitly through the runtime. C++ has very limited run time type information, it can compare types at runtime and perform safe dynamic casts, nothing flashy.
C++ does have templates though, which are more than sufficient to do most of the codegeneration and type inspection tricks that reflection allows - but using the compiler rather than the runtime.
Have a look at http://www.boost.org/libs/mpl/doc/[^] if you are feeling brave
Ryan
|
|
|
|
|
I have a program, that displays this in the debug window when i exit it. Do i have to worry? What does the exit code mean? I thought a healthy program should return an exit code of 0.
The thread 0xF48 has exited with code 2 (0x2).
The thread 0x3B8 has exited with code 2 (0x2).
The thread 0xF70 has exited with code 2 (0x2).
The thread 0xDCC has exited with code 2 (0x2).
The program 'D:\Documents\BarcodeRT ver2.2\Debug\BarcodeRT.exe' has exited with code 2 (0x2).
|
|
|
|
|
An exit code of 2 has no intrinsic meaning, nor does 0. It's the convention that 0 means "app exited normally" but that's not a rule. The process and each thread has an exit code, and the code can be used for whatever purpose the app wants.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Since you have the code you ought to be able to see where the threads are setting the exit code to 2. Hopefully there will be an explaination of what the originall programmer meant by exiting with 2 rather than any other number.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Well, i wrote the program, and it spawns an additional 1 thread. I didnt return any value when i exit the thread, and that's why i'm wondering why it returns a value of 2.
|
|
|
|
|
Um, Could you post a snippet of the code that generates the thread and the function that exits the thread code? That may help?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
in a VC++ SDI application, how to invert the screen, through code.
thank you
Bugfixer
|
|
|
|
|
use this small piece of code that help you to read each pixel of image
or use CXimage lib that wil help you out from this problem
I Think It will Work
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Can some one point me to , a conpletes list of Windows messages , i.e WM_CLOSE , or CPL_DLUBLECLICK
you can send me the link at :
aamir@signalcommunications.com.au
Aamir
|
|
|
|
|
|
Hi all,
Kindly suggest me an efficient way of handling rowsets in SQL CE. My dialog class is bit heavy and I am using the IRowset interface for SQLCE data retrieval. The application hangs when it reaches this method after few test runs. Not able to find where does the problem lie. Please suggest me the necessary resolution.
Thanks in advance,
Mallee
|
|
|
|
|
Hi all,
just wanting to know if it is possible to write code for a new rule or something of that nature that allows me to capture an email coming into my home email, and then parse and retrive data out of it?
I am looking at "Creating a Rule" in "Platform SDK: Exchange Server" but i'm not sure if that will help me, and I would like to use C++ (.Net.. only if absolutely forced to)
thanx
|
|
|
|
|
I was adding some XP flavor to my app so I can get double buffering on my listviews, and what I found out is if I have the manifest file in the directory with the program, it crashes. Without it, it don't.
So I then try to debug the sucker and noticed that WM_INITDIALOG does *NOT* get called first!
WM_NOTIFY and WM_COMMAND are being called first, and crashing.
Can anyone tell me why windows is doing this? I thought WM_INITDIALOG is supposed to ALWAYS be called first! It *IS* always called first without the manifest file though.
I am not using any windows per se, just a Dialog to do all my work.
I then added some code to basically check if WM_INITDIALOG is called, and if not, I return TRUE. What do you know, now my app works fine with all the XP flavored features. I just can't understand WHY it is doing this!
Anyone shed some light on this?
Thanks!
|
|
|
|
|
I`ve been building a program. it runs well in the debug setting, but in the release version, it will bring out an error " could not write to address memory ......". I think it`s the OS. I use win 2000 pro. Any idea?
|
|
|
|
|
|