|
is it possible to log off any system programatically?
if yes how in vc++ and how in csharp?
r00d0034@yahoo.com
|
|
|
|
|
BOOL bStatus = ::ExitWindowsEx (EWX_LOGOFF, 0);
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
please read that code and solve my problem.
Given after that code.
///////////////////////////////////////////////////////////
>>><<<
public class Win32Hook
{
[DllImport("kernel32")]
public static extern int GetCurrentThreadId();
[DllImport( "user32", CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern int SetWindowsHookEx( HookType idHook,
HOOKPROC lpfn,
int hmod,
int dwThreadId
);
public enum HookType
{
WH_KEYBOARD = 2
}
public delegate int HOOKPROC(int nCode, int wParam, int lParam);
private HOOKPROC hookProc;
public void SetHook()
{
hookProc = new HOOKPROC(this.MyKeyboardProc);
SetWindowsHookEx(HookType.WH_KEYBOARD, hookProc, 0,
GetCurrentThreadId());
}
public int MyKeyboardProc(int nCode, int wParam, int lParam)
{
return 0;
}
}
To install the hook procedure
Win32Hook hook = new Win32Hook();
hook.SetHook();
///////////////////////////////////////////////////////////
Above code is 100% correct but my problem here is that I want to execute it for each thread for that purpose I modify a line of code and that is
SetWindowsHookEx (HookType.WH_KEYBOARD, hookProc, IntPtr.Zero,0 );
But after changing that line of code it does not solve my problem because MyKeyboardProc function does not execute its code.
I don’t know why? Can any body give its solution?
r00d0034@yahoo.com
|
|
|
|
|
Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock
|
|
|
|
|
Check out SetTimer() and WM_TIMER
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Basically, use liek this, with ON_WM_TIMER()
SetTimer(1, 3600 000, NULL);
3600 000 here indicates an hour... it's in msec.
so the code would look like.....
int iTimer = 0; //global variable to count time
//this will get invoked every hour
YourClass::OnTimer(UINT nIDEvent)
{
iTimer=iTimer+1;
if(iTimer == 12){
//do your processing....
}
if (iTimer == 24){
iTimer = 0;
}
}//end of fn
hope this helps dude.
jey
|
|
|
|
|
Thanks very much for the direction.
I don't suppose you have some small source files you could send me. I'm new to programming and I have a hard time putting the code in the right place. usually when I see the source files I can just duplicate what was done before and make it work.
Thank again. Mavrock
my email is stonematthies@hotmail.com
|
|
|
|
|
For this waitable timers are best, because (as opposite to WM_TIMER) they do not work only with relative time, but also with absolute time and therefore fire at the right moment even if the machine was down in the mean time, the clock was adjusted or something else.
Check out CreateWaitableTimer() for more info about waitable timers.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
I'm using MFC to write to a file, but it seems that it likes to overwrite the file. I thought the CFile::NoTruncate tag would do it, but I seem to be wrong. I'm using CArchive to do the file I/O.
Thanks for your time =)
|
|
|
|
|
Try:
<font color=blue>CFile</font>::Seek(0, <font color=blue>CFile</font>::end); <font color=green>//Places the file pointer at EOF. Proceed from there... :cool:</font>
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
This maybe too late but good for some old MFC folks like me:
If the file does not exist, create it using CStdioFile:
if (!pfile.Open(fileName,CFile::modeReadWrite))
{
pfile.Open(fileName,CFile::modeCreate|CFile::modeReadWrite);
}
pfile.SeekToEnd();
MFC forever!!!
henryh
|
|
|
|
|
Can anyone give me an idea of some ways to prevent Windows from running applications - all executables???
Thank you in advance...
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Which Windows, what EXEs, WTF do you mean man??!!
Details baby, details....
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
I have wondered this myself and although I have never tried to implement anything I have considered the following as options.
1) Inject some machine code inside each exe calling PostQuitMessage(0)
2) Iterate the processes currently running using a timer and determine which should run or not.
3) You might be able to prevent users from running applications by clicking desktop icons, I think you would wanna read up on shell extensions for more info on how to do this...
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I would look into replacing the windows loader. That way you can decide who gets loaded, from EXE to DLLs.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi!
Is there a way to open a VC7 workspaces with VC6? Is there a converter?
thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
There is no known VC++7 --> VC++6 project converter.
I am building a converter. It will be available next week (probably).
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
cool
I just found out that it is also possible to create a new VC6 workspace and add all source files from the VC7 project. It works
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Gregor S. wrote:
I just found out that it is also possible to create a new VC6 workspace and add all source files from the VC7 project
A VC project is not only a set of files, it's a full makefile. You won't be able that easy to target a given set of files to produce for instance a DLL with shared MFC.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I want the WebBrowser control to draw on my provided window (Static Control) instead of its own window. The actual thing I want to do is to make the WebBrowser invisible and display its contents on my Window.
I have tried exchanging window handles b/w WebBrowser and my Static control but it crashes program. This thing doesnt crash for exchange b/w two static controls and i get to draw what one static is drawing on other one by such exchange. But i want webbroser to draw on my window.
Isnt there anyway tht we override Device Context of WebBrowser.
Anythought are appreciated.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
The web browser is hosted by an ActiveX control site, like any ActiveX, which hides all the complexity of the underlying windows, hence dc and stuff like that. Very unlikely you get to do what you want.
You could ask for the web browser to print (draw to a print dc), while you have selected a fake virtual printer, which you actually control. IMHO, this requires a printer driver (.vxd or something like that), ... Lotsa work!
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I will try it.
Thanks.
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
Hi.
I tried to use CWindow::Print like this by first making the browser window invisible.
So i had no browser shown and still I could get a copy of image on my DC like this.
<br />
m_webBrowser.Print(pMyDC,PRF_CLIENT);<br />
Thanks your idea saved me days.
;););););););););););););););););););););););););)
In my dream, I was dorwning my §orrow§
But my §orrow§, they learned to §wim
|
|
|
|
|
What would make the right context menu that I custom wrote sometimes not show up? It can be doing finec and then sometimes it decides to just not appear anymore. Can I do anything to prevent this?
CMenu menuPopup;
if( rcTHBImage1.PtInRect(point))
{
menuPopup.LoadMenu(IDR_MENU1);
CMenu *pSubMenu = menuPopup.GetSubMenu(0);
CmdRouteMenu(pWnd,pSubMenu);
pSubMenu->TrackPopupMenu(TPM_RIGHTALIGN, point.x, point.y,this,NULL);
}
Thanks,
ns
|
|
|
|
|
Well, there are plenty of things that can cause the menu to not show up (the point is not in the rect, the menu couldn't be loaded, the submenu doesn't exist, etc).
When you encounter a situation like this where the expected doesn't happen, it's best to write the code snippet defensively (in fact it's a good idea to always write defensive code), using ASSERT and VERIFY to check that things are OK. Use TRACE to trace control flow. Here's what I mean:
if (rcTHBImage1.PtInRect(point)) {
TRACE ("Point is in rect...\n");
CMenu menuPopup;
VERIFY (menuPopup.LoadMenu (IDR_MENU1));
CMenu *pSubMenu = menuPopup.GetSubMenu(0);
ASSERT (pSubMenu != NULL);
CmdRouteMenu (pWnd,pSubMenu);
TRACE ("About to display popup menu...\n");
pSubMenu->TrackPopupMenu (TPM_RIGHTALIGN, point.x, point.y, this, NULL);
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|