|
thanks
I'm drinking triples, seeing double and acting single
|
|
|
|
|
I am having problem creating a simple C++ MFC Application using Visual C++ .NET with database support. For database, I use ODBC and selected an Oracle table. Here is the error message:
Microsoft Development Environment
Error occurred while converting the wizard's text to the code page of the existing text in the file: C:\Excercise\db4\db4Set.h
However, if I select a desktop database, for example, a DBF file, the problem does not occur.
Eilzabeth
|
|
|
|
|
I need to catch file system updates for my directory tree
control - that is to say, if anything modifies the directory
tree while my user is browsing, I need to know so he gets
to see the updated view.
So, is there some kind of callback to say "let me know if
the filesystem changes and how" or is there a windows message
that I should be catching?
I know some apps you seem to have to hit Refresh (F5) to get
the system to pickup changes, but I've seen others that seem
to change on the fly and I assume a windows message or a callback was involved. I'm just a little lost on what to look in MSDN for...
|
|
|
|
|
|
*heh!*
Well, it's a nice solution. But it won't work for me. Target platform support is insufficient (I have to support good old
win98 in addition to 2K/XP). But this looks like the way one
would *prefer* to go if one had his druthers, I admit.
Thanks, another good post.
|
|
|
|
|
In that case use the good old fashioned timer and poll the directory structure checking the last time modified date of all the files if "my" solution is unavailbale by checking the OS version. You may be able to get away by just checking the sub directory date/time instead of all the files.
Or for 95/98 add a F5 refresh key!
Hopefully there won't be too many 95/98 systems around
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
start a thread the block it waiting for the hNotify handle to be valid
HANDLE hNotify = FindFirstChangeNotification(_T("C:\\Monitor_this_folder"), TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME |
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE);
while(g_bContinue)
{
WaitForSingleObject(hNotify, INFINITE);
PostMessage(ptr_lparam.hWnd, WM_EX_CHANGENOTIFICATION, 0, 0);
FindNextChangeNotification(hNotify);
}
FindCloseChangeNotification(hNotify);
I got this example from chapter 7 of Windows Shell programming, D. Espisito
you can download on amazon in PDF format
http://images.amazon.com/images/P/B000063UL1.01.LZZZZZZZ.jpg[^]
There's no more in print, yet I have a hard copy!!!
|
|
|
|
|
Beer said:
start a thread the block it waiting for the hNotify handle to be valid
HANDLE hNotify = FindFirstChangeNotification(_T("C:\\Monitor_this_folder"), TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME |
FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE);
Tomb replies:
I'd seen that function.... so it seems my suspicion is confirmed. Will this notify you of changes in subdirs? (ie if I set it for c:\\* (root folder), will it notify of changes in any child dir? or do I have to somehow monitor every folder concurrently (and if so, is there a good way to do this as a whacking pile of threads might not be an ideal choice.... maybe some sort of multiple object wait?)
This looks like what I'm wanting thought.
Thanks muchly.
|
|
|
|
|
kaladorn wrote:
Will this notify you of changes in subdirs? (ie if I set it for c:\\* (root folder), will it notify of changes in any child dir?
Yes, it will, you really should just buy Dino's book, it's full of good stuff.
I'll even let you in on how I got a hard copy of it even though it's out of print!
I bought it used from one of those amazon.com used book dealers. It only cost me thirty bucks too!
If you do any type of shell programming targeted at win98->XP, this book is a must have, you will end up using it for countless numbers of things.
|
|
|
|
|
I'll hunt for the book. I always like buying books that have lasting value and a solid testimonial from someone in the field helps convince me (where I haven't personally seen or leafed the book). I just hate shelling out money for books that quickly obsolesce.
Thanks again!
Tomb
|
|
|
|
|
|
PS: in that example of his you have to type the path of a folder in the edit box, or it the empty field will cause it to crash.
|
|
|
|
|
can anyone help with this function parameters, i cant get them at all
"AdjustTokenPrivileges"
|
|
|
|
|
Security structures in the Windows API tend to be of the 'extensible array' type, where the last field is declared as an array of 1 element, but Windows will actually accept bigger arrays. You can consider the structure you declare as being a header for the full structure.
Let's say, for the sake of argument, that you want to disable the SE_TAKE_OWNERSHIP_NAME privilege (which permits the principal to change the owner of a resource, even if they don't have Write Owner access) and the SE_DEBUG_NAME privilege, which permits the principal to debug processes they don't own.
You would write something like the following:
DWORD dwPrivsSize =
sizeof( DWORD ) + 2 * sizeof( LUID_AND_ATTRIBUTES );
TOKEN_PRIVILEGES* pPrivsIn =
(TOKEN_PRIVILEGES*) malloc( dwPrivsSize );
pPrivsIn->PrivilegeCount = 2;
LookupPrivilegeValue(
NULL,
SE_TAKE_OWNERSHIP_NAME,
&( pPrivsIn->Privileges[0].Luid )
);
LookupPrivilegeValue(
NULL,
SE_DEBUG_NAME,
&( pPrivsIn->Privileges[1].Luid )
);
pPrivsIn->Privileges[0].Attributes = 0;
pPrivsIn->Privileges[1].Attributes = 0;
HANDLE hToken = NULL;
OpenThreadToken(
GetCurrentThread(),
TOKEN_ADJUST_PRIVILEGES,
FALSE,
&hToken
);
AdjustTokenPrivileges(
hToken,
FALSE,
pPrivsIn,
dwPrivsSize,
NULL,
NULL
);
CloseHandle( hToken );
free( (void*) pPrivsIn ); You should save the previous state of the privileges somewhere if you want to re-enable them later. You should also check the return values of all the functions called - this is especially critical in security code.
No warranties for the above code; I just typed it straight into CP's editor
On Server 2003, you can specify SE_PRIVILEGE_REMOVED for the attributes to cause AdjustTokenPrivileges to remove the privileges from the token permanently - they cannot be re-enabled except by creating a new token.
|
|
|
|
|
Hi im writing a dialog based program in mfc ive made a large icon for it and it displays fine for the exe however if i add the program to my quick launch or go to it in a file dialog it shows the default mfc small icon how do i set the small icon for the exe? the regular icon works fine within the program on the system menu so whats the deal why isnt the exe's small icon being set?
Thanks
|
|
|
|
|
In the VC++6 ide, bring up your icon in the resource editor then click on the combo box next to where it says "Device:" above the icon you have open.
Now select Small (16X16) and edit it to your liking.
|
|
|
|
|
Hi
Anyone knows a fn that shut down the pc?!
thanks in advance
|
|
|
|
|
ExitWindowsEx() is the way to go
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks but i tried it, but it only causes the pc to log off, i'm trying it with win XP...
|
|
|
|
|
ExitWindowsEx(EWX_POWEROFF,0)
Here are some notes about using it:
Shuts down the system and turns off the power. The system must support the power-off feature.
Windows NT/2000/XP: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section.
Windows NT/2000/XP: To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege.
John
|
|
|
|
|
There is a framework in MFC where you dont create an SDI or MDI . What I mean is you start off the project with as an MDI but remove the view classes .
This is the MSDN article
HOWTO: Add Multiple Window Types to a Non-Document/View MDI App
ID: Q201045
From within a ChildView how can one manipulate the Toolbar buttons ?
|
|
|
|
|
I think my last post wasn't understandable.
I am trying to create a function that can accept any type of an array as a paramater.
char[] or double[] or int[] etc.
wouldn't it be myFunction(void *data){ do stuff }
char tmp[100];
myFunction(tmp);
I hope this makes sense.
Steven
|
|
|
|
|
Yes that would work, but once inside your function, you have to know what type of array has been passed. You could do something like this:
<code>
enum TYPES
{
CHAR,
DOUBLE,
INT,
...other types...
};
void myFunc(void* data, int data_type)
{
switch (data_type)
{
case CHAR: char* carray = (char*)data;
.... do stuff
break;
case DOUBLE: double* darray = (double*)data;
...etc.
}
...
}
</CODE>
You will probably also want to add a size parameter to myFunc as well, unless all your arrays will be a fixed size.
--Dean
|
|
|
|
|
|
Not being funny, or mean to be offensive, but that's about the worst solution I could imagine in C++.
* it requires massive amounts of work if you wish to add a new type.
* it's still not typesafe - you can't validate what's passed in
* and there are far far better approaches in C++ (eg, templates)
--
Ian Darling
If I was any more loopy, I'd be infinite.
|
|
|
|