|
I use this code :
hFile = CreateFile(
sFileOrFolderName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
And i want to get the handle of folder C:\TEST
What must be the parameter sFileOrFolderName ?
Thank you very much.
|
|
|
|
|
Akin Ocal wrote: What must be the parameter sFileOrFolderName ?
_T("C:\\TEST")
You must also specify the FILE_FLAG_BACKUP_SEMANTICS flag in the passed wFlagsAndAttributes (6th)
parameter.
What are you going to do with the handle?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I want to make an enumration with all SIDs or account names in the system.
How can i enumerate permissions by accounts for a specific file/folder ?
I want to make an output like that :
File : c:\a.dat
ACL ACCESS
-----------------------------
user1 read write
user2 read
user3 write
Thank you very much.
|
|
|
|
|
You can use NetUserEnum() and NetQueryDisplayInformation() to enumerate the user accounts, and then use something like the following to check the access rights:
ace_list* m_sAceList = NULL;
BOOL bSuccess = TRUE;
BYTE* pSecDescriptorBuf;
DWORD dwSizeNeeded = 0;
bSuccess = GetFileSecurityW((BSTR)sPath,
DACL_SECURITY_INFORMATION,
NULL,
0,
&dwSizeNeeded);
if (0 == dwSizeNeeded)
{
return failure;
}
pSecDescriptorBuf = new BYTE[dwSizeNeeded];
bSuccess = GetFileSecurityW((BSTR)sPath,
DACL_SECURITY_INFORMATION,
pSecDescriptorBuf,
dwSizeNeeded,
&dwSizeNeeded);
if (!bSuccess)
{
DWORD dwError = GetLastError();
return failure;
}
PACL pacl;
BOOL bDaclPresent, bDaclDefaulted;
bSuccess =
GetSecurityDescriptorDacl((SECURITY_DESCRIPTOR*)pSecDescriptorBuf,
&bDaclPresent, &pacl, &bDaclDefaulted);
if (!bSuccess)
{
DWORD dwError = GetLastError();
dwError << ")\n";
return failure;
}
if (!bDaclPresent)
{
return failure;
}
wchar_t wszAccName[100] = L"";
DWORD accNameSize = sizeof(wszAccName);
PSID ppSid;
DWORD cbSid = 0;
DWORD cchDomainName = 0;
wchar_t * wszDomainName = NULL;
SID_NAME_USE eSidType;
ppSid = (PSID) new BYTE[1024];
cbSid = 1024;
wszDomainName = new wchar_t[1024];
cchDomainName = 1024;
if (!GetUserName( wszAccName, &accNameSize ) ){
}
if (LookupAccountName( NULL,
computer
wszAccName, ppSid,
size needed,
&cbSid,
wszDomainName,
&cchDomainName, &eSidType ))
{
if (IsValidSid(ppSid) == FALSE)
{
gMessageBox("Error: Invalid SID for %s.", wszAccName);
return failure;
} else {
TRUSTEE trustee;
BuildTrusteeWithSid(&trustee, ppSid);
ACCESS_MASK mask = 0;
DWORD dwRetVal = GetEffectiveRightsFromAcl(pacl,
&trustee,
&mask);
if (!(mask & 65536)){
Assert(false);
return failure;
}
are going wrong...
if (mask & FILE_READ_DATA) DebugOut("can read");
if (mask & FILE_WRITE_DATA) DebugOut("can write");
if (mask & FILE_EXECUTE) DebugOut("can exe");
}
} else {
DWORD lErrorCode = GetLastError();
too small.
if (lErrorCode == ERROR_INSUFFICIENT_BUFFER){
}
}
|
|
|
|
|
Thank you very very much...
|
|
|
|
|
How to use map file for finding the crash in DLL?
|
|
|
|
|
There's a good article here.
Whoops, that's a good article but I actually meant this one
I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^].
Awasu 2.3 [^]: A free RSS/Atom feed reader with support for Code Project. 50% discount on the paid editions for CP members!
|
|
|
|
|
You don't need to use a map file for this. If you built your DLL with debug information (even the release build naturally) your debugger will take you straight to the point of the crash.
Steve
|
|
|
|
|
I have an application which updates itself every time the taskbar's top-level window changes; how will the application's main window be able to be notified of this?
Thanks for your help!
--PerspX
|
|
|
|
|
WM_ACTIVATEAPP
--
=====
Arman
|
|
|
|
|
For a WM_PAINT message, I am writing some text to the window, ultimately with TextOut(), however, I am not sure how to set a font for the current window DC handle...
Thanks for your help!
--PerspX
|
|
|
|
|
You can create the font, which gives you an HFONT (HGDIOBJ).
Then use SelectObject() to select it into the DC.
HFONT hFont = ::CreateFont...
HGDIOBJ hOldFont = ::SelectObject(hdc, (HGDIOBJ)hFont);
...
...draw some text
...
::SelectObject(hdc, hOldFont);
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Why is the following done?
In Project Settings (Alt-F7) under the C++/C tab, set the category to "General" and change the "_DEBUG" preprocessor definition to "NDEBUG".
Under the C++/C tab, set the category to "Preprocessor" and add the preprocessor definition "_DEBUG" to the "Undefined Symbols" edit field.
Recompile using "Rebuild All"
|
|
|
|
|
Is it a quiz, isn't?
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.
|
|
|
|
|
I want to know the significance of changing _DEBUG to NDEBUG and other related stuff.
|
|
|
|
|
Please elaborate and share your thoughts on the following
If you are using DLLs of your own, that use the shared MFC library, make certain that all your DLLs are either debug or release!
Why is it so?
However, it is very important to not have a mix of debug and release DLLs using MFC (note that a "straight", non-MFC release DLL can be called from a debug version of an MFC program
|
|
|
|
|
There's a variety of problems with mixing MFC DLLs.
First, all the DLLs your app uses and all the DLLs the DLLs your app uses are mapped into
the apps address space.
Now say one DLL uses the debug MFC DLL and your app uses the redistributable MFC DLL...
Now there's multiple versions of MFC, one DLL being used by your app, one by the DLL.
The two MFC dlls are probably using different versions of the CRT library.
That means the two MFC DLLs are using different runtime heaps. That can be a problem if you start
passing heap-allocated pointers between your app and dll.
MFC also uses internal static/global variables for caching and mapping handles to objects.
With two MFC DLLs you have two sets of these. If you are using a DLL from your app which uses
a different MFC DLL than your app, then any MFC-related interaction between your app and your
dll is going to be unstable/unreliable at best.
Just my thoughts,
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
That's why I always static-link to MFC DLLs. The extra disk usage is worth it to me to not have to deal with that garbage. Plus, I don't have to make sure the MFC DLLs are installed on my target systems.
Judy
|
|
|
|
|
i want to be able to create vectors as the prgram runs, but all i can think of is something like this
<code>
void create_vector(int index)
{
if(index == 1)
vector<int>number1;
if(index == 2)
vector<int>number2;
if(index == 3)
vector<int>number3;
if(index == 4)
vector<int>number4;
if(index == 5)
vector<int>number5;
}</code>
but i want to do something like this
<code>void create_vector(int index)
{
string name;
name = "number0";
name[6] = (index + 48);
cout << name << "\n";
vector<int>name;
}</code>
thank you
|
|
|
|
|
What exactly are you trying to accomplish?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't think you can assign variable names at runtime.
You could use a map to map runtime strings to a given vector (or to an index to a vector in a
list/array of vectors.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Why don't you create a vector of vectors?
For instance:
vector < vector < int > > number;
then you car reference each (inner) vector with [] operator, e.g.
number[5].push_back(11);
...
You're not creating vectors dynamically but it is not such a memory waste...
BTW you may accomplish dynamically creation with pointers, but IMHO, it is a bit involved using std::vector and pointers togheter.
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.
|
|
|
|
|
What are you trying to do? All I see is a bunch of code that does nothing accept copy “number0” to a string and the change the character “0” to character “index+48”, which assumes index is [0-9].
Neither example creates anything but temporary (stack) vectors and the second one would choke the compiler.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi EvryBody,
I m trying to put a hyperlink over a Balloon styled tool tip and execute a program on click of it. I am able to display the tooltip as balloon with hyperlink onit, but i m not able to click on it. when i try to get the moouse cursor over tooltip, the tool tip disappears, i tried a lot i nothing worked out.
Plz can nybody help me..
Thanks
P.Somasundaram
|
|
|
|
|
somasundaram_be wrote: I m trying to put a hyperlink...
Which is what type of control (e.g., static)?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|