|
Mark Salsbery wrote: Fishing season is OPEN!
Didn't you get the memo? The season opens on January 1st at 00:00:00 and closes on December 31st at 24:59:59
Here's another[^]
led mike
|
|
|
|
|
Good one, thanks!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
AbortSystemShutdown()
http://msdn2.microsoft.com/en-us/library/aa376630(VS.85).aspx[^]
Sample Usage:
BOOL AbortShutdown(LPTSTR lpMachineName)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
BOOL fResult;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
TRACE("OpenProcessToken failed.\n");
return false;
}
LookupPrivilegeValue(lpMachineName, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
{
TRACE("AdjustTokenPrivileges(setting) enable failed.\n");
return false;
}
fResult = AbortSystemShutdown(lpMachineName);
if (!fResult)
{
TRACE("AbortSystemShutdown failed.\n");
return false;
}
else
m_bIsShuttingDown = false;
tkp.Privileges[0].Attributes = 0;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
{
TRACE("AdjustTokenPrivileges(re-setting) disable failed.\n");
return false;
}
return true;
}
|
|
|
|
|
|
Mark Salsbery wrote: Service Control Handler Function[^]
Sounds more like a candidate for the Buzzword hall of shame forum.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: Mark Salsbery wrote:
Service Control Handler Function[^]
Sounds more like a candidate for the Buzzword hall of shame forum.
Nope , it's actually a very concise description of the subject at hand - the specifics of the function which handles control messages for a service. MS surprisingly actually titled the page with meaningful text.
Judy
|
|
|
|
|
Thanks everyone for the help. The AbortShutdown() is what I was looking for. I know about the WM_QUERYENDSESSION message and how to handle it. Originally, I was looking for a way to get around the hidden window in my service, but because I have to interact with my user, I must use it.
|
|
|
|
|
If anyone can please write a simple function using the low-level keyboard hook WH_KEYBOARD_LL i would greatly appreciate it, although i use boralnd builder 6 instead of visual the concepts are still the same, i would apprciate a function that sets/unsets the hook and just a simple hook declaration, i've read the post/topics about it but i just cant seem to get it to work. help please
|
|
|
|
|
There's an article here[^] which demonstrates the same.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
codinelogic wrote: i've read the post/topics about it but i just cant seem to get it to work.
Show us what you've tried.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
defines and includes included [hehe]
<br />
#define WIN32_LEAN_AND_MEAN<br />
<br />
#define STRICT<br />
<br />
#include <windows.h><br />
<br />
HHOOK hKeyboardHook;<br />
HINSTANCE hInst;
and than the hook along with the on off function..
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) <br />
{<br />
PKBDLLHOOKSTRUCT k;<br />
<br />
if (nCode == HC_ACTION) <br />
{<br />
k = (PKBDLLHOOKSTRUCT) lParam;<br />
<br />
if (
here is where i will choose to disable keys
return 1;<br />
}<br />
<br />
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);<br />
}
the turn on...
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,<br />
LowLevelKeyboardProc,<br />
hInst,<br />
0);
the turn off..
UnhookWindowsHookEx(hKeyboardHook);<br />
hKeyboardHook = NULL;<br />
a note: without define strict i receive an error in the lpfn parameter.
also it will compile without win23_lean_and_mean but while reading
other's articles it seemed recomended.
|
|
|
|
|
If you are receiving a compiler error, what is it, and what line is it on?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Editor VS6
Language:VC++
my task is to run the DOS cmd from my application (ie on button click)and redirect the output in my applications Edit box without showing the console window
how to do it ...........
Code is preffered
AbidBhat
|
|
|
|
|
abid wrote: Code is preffered
I bet, but around here we prefer people write their own code. Read the first post in forum titled "How to get an answer to your question".
led mike
|
|
|
|
|
abid wrote: how to do it ...........
See here and here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have problem in SDK/ MFC.
I have to assign/map 'Down' or 'Up' arrow key to a specific character suppose letter 'D' or 'U' or any other character. So that when i press 'D' or 'U', it acts or function like a Up or Down arrow key..
How can i do this, please help me.
Thanks in advance..
|
|
|
|
|
You want such functionality within your application or system-wide? If it is just your application, overriding PreTranslateMessage() may help you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Handle the 'D' or 'U' and call the same code that you call when handling the 'up' or 'down' keys.
|
|
|
|
|
Maximilien wrote: call the same code that you call when handling the 'up' or 'down' keys.
He may not have any code to be called while the up or down arrow keys are pressed. I understand that his requirement was to just simulate an up arrow key press while 'U' is pressed and down arrow key press if 'D' is pressed.
Also, how do you handle 'D' or 'U'? Say, if there are multiple child controls in the application window, those child controls may be having the keyboard focus!
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi,
How can I change the background color of CToolBar ?
Regards,
Paresh.
modified on Monday, February 18, 2008 1:17 AM
|
|
|
|
|
I'm writing my first shell extension dll, and I'm trying to figure out how to pass the Recycle bin files/folders anme CShellExt::InvokeCommand at right click of menu item. I am getting others files and folders name.
Some sennipt is attached.
<br />
void CCoMenHandler::GetSelectedFiles(LPCITEMIDLIST pidlFolder,IDataObject *pdtobj)<br />
{<br />
g_szSelectedFiles.RemoveAll();<br />
<br />
if (pdtobj) <br />
{<br />
pdtobj->AddRef();<br />
<br />
STGMEDIUM medium;<br />
FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};<br />
<br />
<br />
HRESULT hr = pdtobj->GetData (&fe, &medium);<br />
if (FAILED (hr))<br />
{<br />
return ;<br />
}<br />
<br />
char path[MAX_PATH];<br />
<br />
UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF,<br />
path, MAX_PATH);<br />
<br />
if (fileCount>0)<br />
{<br />
g_szSelectedFiles.SetSize(fileCount);<br />
<br />
for (UINT i=0;i<fileCount;i++) <br />
{<br />
memset(path, 0, MAX_PATH);<br />
if (DragQueryFile((HDROP)medium.hGlobal, i, path, MAX_PATH)) <br />
{<br />
g_szSelectedFiles.SetAt(i, path);<br />
}<br />
}<br />
<br />
g_szSelectedFiles.FreeExtra();<br />
}<br />
<br />
ReleaseStgMedium(&medium);<br />
}<br />
<br />
<br />
}<br />
Thanx in advance.:
|
|
|
|
|
Hello everyone,
Unique pointer should not allow aliasing. But my code which contains unique pointer aliasing and also compile/run ok. Anything wrong?
__interface IFoo {
public:
virtual int foo ([unique] char *ptr1, [unique] char *ptr2) = 0;
};
class Foo : public IFoo {
public:
int foo (char *ptr1, char *ptr2)
{
char array1[] = "Hello";
ptr1 = array1;
ptr2 = array1;
return 0;
}
};
int main()
{
char* ptr1 = 0;
char* ptr2 = 0;
Foo f;
f.foo(ptr1, ptr2);
return 0;
}
thanks in advance,
George
|
|
|
|
|
Hi Friends,
I want to export a class and its static member from the DLL.
I could build the DLL.
And i want to use that exported class and its static members form that Dll in my C++ application. But when i am building application i am getting a link error for that static member.
error LNK2001: unresolved external symbol "public: static int CMyClass::i" (?i@CMyClass@@2HA).
The IDE that i am using is Visual Studio 6.0.
Plz help me
The details of the implementation is as follows...
//////////////////////DLL PART//////////////////////////
// MyClass.h: interface for the CMyClass class.
//---------------------------------------------
#define _MYDLL
#ifdef _MYDLL
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
class MY_API CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int i;
};
// MyClass.cpp: implementation of the CMyClass class.
//-------------------------------------------------
#include "stdafx.h"
#include "MyClass.h"
int CMyClass::i;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
//////////////////////////////CALLING APPLICATION//////////////////////////
In my application i try to use that static member as below;
#include "MyClass.h"
_tmain()
{
int nValue = CMyClass::i;
}
|
|
|
|
|
See here [^]
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
I corrected the code as follows.
And i defined _MYIF in the project settings.
The Dll could build successfully.
But when i ma using this in amy application , it is showing an error
error LNK2001: unresolved external symbol "public: static int CMyClass::nValue" (?nValue@CMyClass@@2HA)
Plase see the classs impelmentation as follows.
Does any have any idea?????
//MyClass.h
#ifdef _MYIF
#define MY_API __declspec(dllexport)
#else
#define MY_API __declspec(dllimport)
#endif
class MY_API CMyClass
{
public:
CMyClass();
virtual ~CMyClass();
public:
static int nValue;
};
//MyClass.cpp
#include "MyClass.h"
int CMyClass::nValue = 0;
CMyClass::CMyClass()
{
}
CMyClass::~CMyClass()
{
}
|
|
|
|