|
|
Programs under windows need administrator privilege must get user's permission when they start. And they can also run with administrator privilege by right click the EXE and select "Run as Administrator". But, before the EXE start, a message box will show up. It's really disgusting.
Now I want my application to run as the Administrator, and I don't want the popup message box when user click the EXE file.
Now I wonder whether AdjustTokenPrivileges can help me achieve this.
Any one can help me?
modified 18-Aug-12 10:13am.
|
|
|
|
|
This has nothing to do with C++/MFC, please choose a forum more appropriate to the subject. You may find that the most appropriate forum is Google itself.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
So you want your program to run as an admin without notifying the user, or getting the admin's permission?
Sounds like malware to me.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
1. This program displays a running counter starting from 0 till infinity. The counter starts/resets by pressing enter and stops by pressing some other key. Use as many define directives and macros to achieve this task. The counter when played should be like a real counter (no separate line should be used for the
next counter increment). Hint: use clrscr() command inside the for loop.
|
|
|
|
|
Please try and do your own homework. If you get stuck on a particular part of the code then post a question here, but do not expect others to provide an entire solution without any effort on your part.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
It was not homework.I saw that question in book and Dont know how to solve it.So i thought to ask The Experts to help me.
|
|
|
|
|
Experts will help you, but you are expected to make some effort for yourself first.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Try not to re-post the question. Have patience to get answers.
|
|
|
|
|
Why is there a "1." preceding the text? Were you going to ask a second question? What's with the "Hint:" at the end?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
roza123 wrote: Use as many define directives and macros to achieve this task.
Whoever wrote that exercise should be fired.
Asking for bad coding practice at that level is just asking for troubles.
Watched code never compiles.
|
|
|
|
|
It's from a book according to OP; goodness knows who wrote it.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
Challenge accepted.
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <stdio.h>
using namespace std;
#define KB_UP 72
#define KB_DOWN 80
#define KB_LEFT 75
#define KB_RIGHT 77
#define KB_ESCAPE 27
#define KB_F8 66
#define KB_ENTER 13
int KB_code=0;
int ch=0;
int ON_OFF_SWITCH=-1;
unsigned long int counter=0;
void gotoxy(int x, int y);
void clrscr();
void do_keyboard_processing_stuff(void);
int main(void)
{
while(KB_code != KB_ESCAPE )
{
if (ON_OFF_SWITCH==1) counter++;
gotoxy(22,10);
cout<<"Infinity Counter = "<<counter<<" ";
do_keyboard_processing_stuff();
}
cout<<"\n\n";
return 0;
}
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
return;
}
void clrscr()
{
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
return;
}
void do_keyboard_processing_stuff(void)
{
if (kbhit())
{
KB_code = getch();
if (KB_code!=KB_ENTER) ON_OFF_SWITCH=-ON_OFF_SWITCH;
switch (KB_code)
{
case KB_ESCAPE:
break;
case KB_LEFT:
break;
case KB_RIGHT:
break;
case KB_UP:
break;
case KB_DOWN:
break;
case KB_ENTER:
clrscr();
counter=0;
ON_OFF_SWITCH=-1;
break;
}
}
}
|
|
|
|
|
You're missing a few macros in there!!!
Watched code never compiles.
|
|
|
|
|
You're right. I totally missed the macros part.
|
|
|
|
|
I can predict the next posting... "I ran your code and it never reached infinity what could the problem be?"
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
|
Hi,
I have a question about information provided by the exception handler
My Background is on the MainFrame there Z/OS MVS via RTM (Recovery Termination Manager)
provides information about the abend in a COntrol block SWDA (System Diagnotic Area)
The Recovery Routine (ESTAE,ARR,FRR) provides the abilty to do a retry of the Aborted
Task
Does the FRameWork (AFX) provide anything besides a catch routine for the code that is
problematic
Thanks
|
|
|
|
|
What exactly is your issue in terms of C/C++/MFC? What frame work are you talking about?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
you code a Catch pargraph and an excpetion happens somewhere in your THREAD the catch block is executed but you really don't know where in your code it happened
Thanks
|
|
|
|
|
I know how to code a catch block, I was just wondering whether you had posted in the correct forum. When you catch the exception it should contain sufficient information for you to discover what went wrong in your code.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
// don't know where in your code it happened
Let your debugger stop at any exception
(IDE::Ctrl+Alt+E in a loaded solution)
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
To my knowledge, MFC does not contain tools for managing task transactions. There is no common framework for managing undos, redos, etc...
The try / catch mechanism is a simplistic implementation of such a system, built into C++ that allows a program to gracefully unwind from an aborted task. the Afx classes that support exception handling, simply build upon this framework.
I have seen articles that discuss transaction processing for the windows file system and other kernel elements, coming up in future releases, but at this time, I don't know much about it.
You'll likely find that you'll need to roll your own Transactional Tasks manager for your application.
|
|
|
|
|
Folks Quick Question:
I have a dll developed in c#, which does some interactions with a web service, this all seems to be fine. I have made the dll visible to COM. I then register the dll using regasm passing it a /codebase /tlb argument. Again all this works fine. I now get a tlb file. From here i reference the tlb in my VC6 project like so:
#import "C:\\epos\\MyInterface.tlb" raw_interfaces_only
using namespace MyInterface;
Once i compile the VC++ project i get a tlh file generated, which has the following contents (edited there is much more in this file just showing what is needed here):
.tlh File generated by VC6
#pragma once
#pragma pack(push, 8)
#include <comdef.h>
namespace MyInterface {
>struct __declspec(uuid("2172ffe3-3177-3e81-ac7a-9d27e11be389"))
IMyLink;
struct CMyLink;
_COM_SMARTPTR_TYPEDEF(IMyLink, __uuidof(IMyLink));
I create COM earlier in the program so i have not included it in the code below.
Then i Create an instance of the c# class, to call the methods i need. Now this all works fine and i can call these methods and they work correctly.
Code in my Main.c file
IMyLinkPtr iPtrMyLink; IChVRspPtr iPtrCheckVRsp;
void main()
{
short blnRetVal = 0;
IChVReqPtr iPtrCheckV(__uuidof(CChVReq));
HRESULT hrRetval= E_FAIL;
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink));
iPtrMyLink->CallMethod1(iPtrCheckV, &iPtrCheckVRsp, &blnRetVal);
}
The problem i am having is that my program crashes after some time where the memory has grown to 32mb, which to me is quite low. The crash occurs on a CreateInstance line, not necessarily the one above but some other method i have to another .net dll. My main question is about memory, before calling this line:
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink));
The memory in the VC6 app is 12mb, once this line is called the memory jumps to 24mb. Is this down to loading the .net Framework and if i have another dll that does the same the memory will jump to 32mb and will crash shortly after when attempting to create an instance again. I am releasing the objects so im not sure what is going on here.
Any ideas appreciated?
|
|
|
|