|
if you control both OnChar and onkeydown, it should work.
This is the note given in MSDN explaining the correct scenario explaning that you cant fool the system .
Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
in your case map the EN_UPDATE ,check wether the characters are integers and if the count goes above 10 , you do the required .
Regards
FarPointer.
|
|
|
|
|
Actually that's what I originally did except that I used EN_CHANGE, which may have been a mistake. Although a similar approach had worked before, this time I somehow got an odd character at the beginning of the string when I re-read it from the edit control.
Using a combination of OnChar to filter the input and EN_CHANGE to process the string at least would have the benefit of reducing my logic's complexity.
Lilith
|
|
|
|
|
I want to build an application which is determine the time a customer use a computer (a netcafe' software, like that). But a customer can easily endtask my application with TaskManager. Is there a way to prevent the app ended by the user ( the user may be log on admin acc) ? I know many program cant be endtask (and the most is viruses ~.~), but I dunno the tech. This is not just prevent user open TaskManager.How I solve this problem ?
Tnx all.
-- modified at 22:09 Friday 13th January, 2006
|
|
|
|
|
The best way would be not to get tricky and simply use the normal security architecture - ie. Not let the user log on as an administrator and set up permissions so they can't kill stuff. If, for some reason, this isn't feasible, it is possible but beyond most programmers (including me). Check out this - Read the bit under the "Kernel-mode Rootkits" heading. This would have to be done in kernel mode which is nothing like user mode programming and where mistakes are fatal. After going to all this trouble you might find that virus scanners and other tools think your app is a virus or rootkit.
Steve
|
|
|
|
|
a technique i have used is to run two processes -- let's say your app is tracker.exe, i would use tracker.exe and tracker_helper.exe. basically in both apps, use the WaitForSingleObject function, to wait for the other's process handle. if it is killed, just respawn the other process again.
of course this will be conspiciouos, if you want to stop people from seeing that you are doing this, maybe use srvtasks.exe or something kernel-sounding for the second one and put it in a system folder. (possibly ????)
still, if the user knew what they were doing, they could write an app to kill both processes simultaneously. if you don't want that, you can probably write a security descriptor for you main process and apply it somehow (sorry, can't help you there). if you have norton antivirus you can try to kill navapscv.exe and see what i mean.
hope that helps
|
|
|
|
|
I need to start another process from my program and pass it some arguments. Anyone know how to do this using VC++.Net Under Visual Studio 2003? Please Help if you can. Thank you
Pablo
|
|
|
|
|
You could use the "CreateProcess" API. Here is what a typical call would look like:
-----------------------------------------------------------------------------------
STARTUPINFO si = {0};
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
BOOL bOk = CreateProcess(
"C:\\Windows\\System32\\Notepad.exe", // LPCTSTR lpApplicationName
NULL, // LPTSTR lpCommandLine,
NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes,
NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes,
FALSE, // BOOL bInheritHandles
0, // DWORD dwCreationFlags
NULL, // LPVOID lpEnvironment
NULL, // LPCTSTR lpCurrentDirectory
&si, // LPSTARTUPINFO lpStartupInfo
&pi // LPPROCESS_INFORMATION lpProcessInformation
);
if ( bOk )
{
pi.CloseHandle(pi.hProcess);
pi.CloseHandle(pi.hThread);
}
There are other options like "ShellExecute" and "ShellExecuteEx" and CRT functions such as "_spawn".
Steve
|
|
|
|
|
I want to be able to cause Microsoft Word to load(run) with a particular ".doc" displayed and when the user finishes the document and selects the [-] min or [X] close button in Mircosoft word the user returns to exactly where he/she left off in the program.
How can this be done AUTOMATICALLY from within a program? EXAMPLE of working code PLEASE!
C++ is my favorite programming language
|
|
|
|
|
You can call a ShellExecute on the filename of the doc you want to open.
SHELLEXECUTEINFO sei;
ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO));
sei.cbSize = sizeof (SHELLEXECUTEINFO);
sei.lpVerb = "open";
sei.lpFile = curPath;
sei.nShow = SW_SHOW;
sei.hInstApp = NULL;
sei.lpDirectory = strPath;
sei.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS;
sei.lpParameters = NULL;
ShellExecuteEx (&sei);
Where curPath is the filename (including path) and strPath is the name of the working directory.
This will call the default program for the specified filetype to open with that file. If the user has a different program defaulted for opening up .doc files (like wordperfect or something), then this will not open word.
Kelly Ryan
|
|
|
|
|
Hi ,
I guess you need to use automation ,by this way you export all the function provided by the word type library, you can do all the sort of work in that word like if the user is doing it, you can set the setuservisible(true),("i guess so ") ,and that word becomes visible to the user ,
i havent tried this on word, but on excel and it works wonderfully.
Regards
FarPointer.
|
|
|
|
|
I would like to know how to send a shortcut to the desktop from within a program?
Can anybody give me a working example?
C++ is my favorite programming language
|
|
|
|
|
|
Hi,
I have a VC++(mfc) classes written especially as base class for enhancing menu's in MFC modules.
Now i want to make use of this classes(vc++)for enhancing menu's in a vb6.0 module aswell. So these classes will be accessed by mfc & vb at same time.
1. How do i do this, do i create a dll?, if so what dll?, there are diff options in MFC wizard, which one do i choose to create?
2. Do i need to make any modifications in existing classes to export to VB
Please anyone give me an Idea.
Thanking you
Mo
|
|
|
|
|
what does your MFC class do?
just some menu functions (i.e. delete menu item) or a visible menu interface?
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
It loads different menu's from resource(.rc) according to the doctemplate & adds icon to it,plus adds some other enhancments.
Mo
-- modified at 6:55 Saturday 14th January, 2006
|
|
|
|
|
I am extremely fed up with the resource editor in VS2005. Not only does it regularly crash VS2005 (usually when adding a new dialog), I am now having problems adding a variable from the dialog editor to an associated class.
My Setup in my solution:
- I have a resource only dll that contains only the resources and not the code behind it. In other words it basically only has Resource.rc file and Resource.h file.
- Another project (a library) contains the source code associated with the dialogs and property pages in the Resource.rc file.
- The way I associated the Resources with the code was by adding the Resource.rc file into the other project (the library) and then excluding it from the build.
This seemed to work at first. When I go to add an event handler for say a button, the handler gets added just fine into the correct .cpp and .h file that corresponds to the dialog that contains the button.
The issue I am having is, when I right click on the same button and select "Add Variable", the "Control Id" field is blank and disabled. The Control Id of the button is supposed to be filled in. Why is this happening? If it can add a handler properly, why can't it add a variable?
Also, is there a better way of associating the resources with the code when the resources are contained in a resource only dll and the code in a separate project?
Please Help. This has been frustrating me ever since we upgraded VS 6.0 to VS 2005.
Thanks in advance.
|
|
|
|
|
Hello all,
I am writing an assert function and don't know how to do certain things,
1. How can I know the file name of the code that cause the assert?
2. How can I know the line number of the code that cause the assert?
3. How can I know the function name of the code that cause the assert?
4. How can I print out the call stack when I get the assert?
5. Can I get the PC and SP register information when I get the asset?
Thanks!
Nacho
|
|
|
|
|
1. How can I know the file name of the code that cause the assert?
A: The "__FILE__" macro.
2. How can I know the line number of the code that cause the assert?
A: The "__LINE__" macro.
3. How can I know the function name of the code that cause the assert?
A: Possible but hard - See 4.
4. How can I print out the call stack when I get the assert?
A: There are article on the codeproject and else where on this - It is a bit involved.
5. Can I get the PC and SP register information when I get the asset?
A: Inline assembler:
#pragma optimize("y", on) // Force use of frame pointers
DWORD GetMyReturnAddress()
{
DWORD ReturnAddress;
__asm
{
mov eax, [ebp+4]
mov dword ptr[ReturnAddress], eax
}
return ReturnAddress;
}
#pragma optimize("", on) // Resets the optimizations
DWORD _ESP;
__asm
{
mov dword ptr[_ESP], ESP
}
DWORD _EIP = GetMyReturnAddress();
Steve
|
|
|
|
|
1: The __FILE__ macro.
2: The __LINE__ macro.
3: The __FUNCTION__ macro.
4: This requires that you be able to manipulate the symbolic debugging information for the program in question. Essentially, you have to be able to do the same things as a debugger. This is not trivial, and requires detailed specifications of the debugging symbols, which isn't always available.
5. Yes. Generally, in C, on entry to any given function the top-most item on the stack is the return address. Just above the return address are any function arguments. Since you are now inside your assert function, and you (I would assume) know the arguments, you can 'back up' the stack pointer to reach the stack contents at which your assert function was called.
The question remains, why are you implementing your own assert function?
assert is provided for you.
Software Zen: delete this;
|
|
|
|
|
Gary R. Wheeler wrote: The question remains, why are you implementing your own assert function?
assert is provided for you.
I don't know Nacho's reason, but I have the need to be able to comprehensively report an error (file, line, function, and stack trace) and then continue the program with error recovery.
The idea is that a customer could snap the info and report it back and then I would have a fighting chance of figuring out the problem. And if automatic error recovery worked, then the customer is not facing a complete crash like assert() gives.
Further, not all code runs under Windows. An heretical thought, but there it is!
|
|
|
|
|
Harold Bamford wrote: not all code runs under Windows
assert is a Standard C/C++ library feature, and it not Windows-specific.
Software Zen: delete this;
|
|
|
|
|
But it does cause an abort. Not always a nice thing for an embedded system. Thus the need to write an alternative.
|
|
|
|
|
Hi,
I'm writing a network application and I need to retrieve informations about network computers : MAC address, Host Name, IP, shared resources...
I suppose something suitable exists in Microsoft API but I don't know where.
I've tried Windows Networking but it seems a bit limitated.
Can someone help?
Thanks
|
|
|
|
|
Winsock API in MSDN will be a good place to look for the information you require.
Z.A
|
|
|
|
|
zubair_ahmed wrote: '06
Winsock API in MSDN will be a good place to look for the information you require.
AFAIK and IMHO, Using Winsock api you can only transfer data, you cannot recv any network or lan related data.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|