|
Peter, Chan wrote: Do I need to delete Arr when it is useless.
In this case, no. Since you did not allocate the strings using new , you do not have to free them using delete .
|
|
|
|
|
I've got a bitmap on a button and I want the user to be only able to click the area of the button that is covered by the bitmap.
For circular bitmaps I've used the following code:
CRect button_rect ;
HRGN rgn ;
button->GetClientRect ( &button_rect ) ;
rgn = CreateEllipticRgn( 0,
0,
button_rect.Width(),
button_rect.Height() );
button->SetWindowRgn ( rgn,
TRUE ) ;
However I've got a bitmap that has a rectangle that is diagonal across the bitmap, does anyone know how I can create a HRGN object with the points for the diagonal rectangle.
TIA,
|
|
|
|
|
I think you can use CreatePolygonRgn(...)
Also, you can use the CRgn wrapper instead of HRGN:
CRgn rgn;<br />
CPoint pt[3];<br />
pt[0].x = 10;<br />
pt[0].y = 10;<br />
pt[1].x = 100;<br />
pt[1].y = 100;<br />
pt[2].x = 10;<br />
pt[2].y = 100;<br />
<br />
rgn.CreatePolygonRgn(pt,3,ALTERNATE);
this is this.
|
|
|
|
|
thanks for your reply, got it semi working using this just need to get my polygon region the right shape/size now!
cheers,
|
|
|
|
|
I cant get SACL structure of a file , however i call a function : Privilege(SE_SECURITY_NAME,TRUE);
How can i get sacl ??
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
//
// obtain the token, first check the thread and then the process
//
if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, TRUE, &hToken)){
if (GetLastError() == ERROR_NO_TOKEN){
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return FALSE;
}
else
return FALSE;
}
//
// get the luid for the privilege
//
if (!LookupPrivilegeValue(NULL, pszPrivilege, &tp.Privileges[0].Luid))
return FALSE;
tp.PrivilegeCount = 1;
if (bEnable)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
//
// enable or disable the privilege
//
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
return FALSE;
if (!CloseHandle(hToken))
return FALSE;
return TRUE;
}
|
|
|
|
|
Hi all,
Lets say one has a struct like: And this struct has data in it. Is it possible to empty the struct without using a loop (to clear out each of the variables data in the struct?)
#define BUF_SIZE 100
struct fee
{
char bufOne[128];
char bufTwo[128];
}FOO[BUF_SIZE];
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
::ZeroMemory(&Foo[0], sizeof(fee) * BUF_SIZE);
or
memset(&FOO[0], 0, sizeof(fee) * BUF_SIZE);
Manish Rastogi
|
|
|
|
|
manish rastogi wrote: ::ZeroMemory(&Foo[0], sizeof(fee) * BUF_SIZE);
or
memset(&FOO[0], 0, sizeof(fee) * BUF_SIZE);
Thanks for the response ..
Q: Would that clear the entire struct and all of it's members?
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
|
|
memset(FOO, 0, sizeof(FOO));
|
|
|
|
|
|
I would like to modify the menu that pops up when the mouse is right-clicked on the clock in the system tray. I want to add another entry below "Customize Notifications..." in the menu. Is this possible? If so, please point me in the right direction.
|
|
|
|
|
I assume you would have to use DLL injection for this and add your own menu item into the clock menu from your injected DLL..
--PerspX
|
|
|
|
|
I already had a DLL injected into the clock, but how do I trap the popup of the menu and modify it? Do I intercept WM_NOTIFY messages?
-- modified at 9:34 Wednesday 4th July, 2007
I figured it out. In my hooked WndProc(), I needed to return DefWindowProc() on WM_NCHITTEST rather than CallWindowProc(). Once I did that, I was getting WM_RBUTTONUP and that's the place to show the context menu.
|
|
|
|
|
OK good glad I could help
--PerspX
|
|
|
|
|
I am doing everything for allocating and freeing sid structure but it always gives leakages please check the code :
BOOL GetAll (char* sFileOrFolderName )
{
DWORD dwRtnCode = 0;
PSID ownerSid = NULL;
HANDLE hFile;
hFile = CreateFile(
sFileOrFolderName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
return FALSE;
}
dwRtnCode = GetSecurityInfo(
hFile,
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION,
(&ownerSid),
NULL,
NULL,
NULL,
NULL);
if( !ownerSid )
{
CloseHandle(hFile);
return FALSE;
}
LocalFree((HLOCAL)ownerSid);
CloseHandle(hFile);
return TRUE ;
}
int _tmain(int argc, _TCHAR* argv[])
{
while(1)
{
if(!GetAll("d:\\aa.txt"))
{
printf("\nFailed");
}
Sleep(1000);
}
return 0;
}
|
|
|
|
|
Akin Ocal wrote: ...but it always gives leakages...
How are you verifying these "leakages?"
"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
|
|
|
|
|
Hi! Here's the problem:
I have an exe (no source code) wish for it to run only when it finds a valid license on the pc. Therefore I wish to modify it somehow (wrap,modify, etc) so that it will check for certain criterii such as hardware id before launching itself.
What I've found out so far:
I know I can create another exe that embeds the exe using Visual Studio. However, running the exe from memory only applies to .Net exe. I wish to cover non .Net too. And I know that running non .Net exe from memory is very hard.
Question:
How do i do this? Is there a way to modify the exe so that I can insert checking codes before the exe launches normally?
Thanks!
"Long is the way, and hard, that out of hell leads up to light."
|
|
|
|
|
|
Offcourse you can.
You can add the exe as a resource of another exe. So Only if you find a valid licences for a coputer, extract the exe from the resorce, write it as a file and then use ShellExecute or CreateProcess to run the original exe.
In this case there is a change that the user can extract the exe from the resource and save it as another exe. To prevent this, add some encrytption to the file before you add it to the resource.
|
|
|
|
|
Naveen.R wrote: To prevent this, add some encrytption to the file before you add it to the resource.
How does that prevent it?
|
|
|
|
|
A simple example. Suppose I cut first 10 bytes of exe and put at the end of the file. Then the exe will not be executable isnt't it? So after extracting I should roll back this changes, means i copy the last 10 bytes and put it in the begining. then execute the exe.
|
|
|
|
|
Well but in executing it, unless we run in from memory straight, the user could still copy the correct exe while it's running. Doesnt solve the problem?
|
|
|
|
|
I have foudn some applications like ie creates some temp file while browsing some sites( for ex if you took a video in the youtube, you can see a "temp" file created in the temporary internet folder.I noticed that that file cannot be renamed or copied or deleted. If we kill the IE, that files get deleted automatically. May be you implement the same technique. I dont know how IE does this. If you got any information, tell me also.
Other option is to make a loader by your self.May be very difficult.I shall inform you if i got any other solutions.
|
|
|
|