Visual C++ :: How To Log Off A User When Workstation Is Locked
Nov 30, 2013
I wrote a Windows application that comes with two modules: service and user-mode exes. The service implements its own scheduler and may log-off a user at a predefined time. For that I was using the following call that is triggered from my user-mode module exe in a logged-on user session that has to be logged off:
Code : BOOL result = ExitWindowsEx(EWX_LOGOFF, reason);
This works fine, except of the situation when a user's account is locked. In that case that API doesn't seem to do anything at all even through I get 1 returned from it.
So I was curious, is there any other way to log off a user when their account is locked? (One condition I have in this case is that if that user had any unsaved documents then the log-off should not be forced.)
I have a button that opens a file dialog box so that a user can pick a file. I only need it for the path and file name to be passed to another program. I do not want to open the file or care about its contents. I just want the name and path.
The problem is that as long as the program is running the file that the user picked is locked for editing. Adding the Dispose() had no affect. Multiselect and ReadOnlyChecked have no affect. Only closing the application frees the file.
I'm trying to connect to a SQL Server Database, but when I click my button1 my entire form just locks up and nothing happens! I have to click the "Stop" button to stop the form from running in Visual Studio! I'd at least expect to receive an error if some of the connection string was wrong.
Here is my code:
private void button1_Click(object sender, EventArgs e) { connection(); } public void connection() { SqlConnection myConnection = new SqlConnection();
I have been using the code below to extract the current user directory in order to read and write to certain files, presumeably independent of whether or not the user has administrative privileges. This has been necessitated in Win 7 because applications installed in the customary C:/Program Files(x86)/ are not allowed full access to files in the installed app root directory. This was working just fine until just this week when suddenly, for the first time, I found that the user directory retrieved was different when the app was run without administrative privileges in 'Start without debugging' configuration, both in Debug and Release configuration. Note that I have tested the identical app on Win2K and Vista and in neither case is it a problem on those OS machines. More mysterious is the fact that this ONLY happens on Win7 (VS2010 Ultimate) when run in the IDE. Run from the windows explorer double click, the app runs just fine in release and debug mode and monitoring the debug version using DbgView indicates that the expected 'Roaming' User directory is retrieved.
For example:
- without debugging (both Debug and Release configuration) the code below produces:
Either this has been the situation from the outset and I just never noticed it (hard to imagine as I've been on this project for 6 months with 50+ builds), a recent Windows update has changed things, a bug, or I'm just plain stupid (not hard to imagine at all).
From a practical standpoint, if this is the way things are to be, my installer will need to install necessary files in both user directories and the app will need to access both depending upon user privileges.
Code: /// This routine retrieves the process's environment block /// using GetEnvironmentStrings, parses that block pointed to /// by the generic international text pointer LPTCH, and returns /// the requested string lpszVarStr as a string. /// Note that the block lpvEnv environment variable substrings /// are separated by NULL byte, and the block is terminated by a NULL byte. /// The header files <windows.h>, <tchar.h>, <stdio.h>, <string>, and /// <iostream> need to be included.
I want to have a multi user chat over TCP/IP. I already have the code for both the server and the client and so far I am able to send messages from the client to the server. Now I want to make it a multi user chat. I am executing the codes using Visual studio's Command prompt(not Windows Command Prompt). I have read somewhere that we have to use select() function.
My program was to allow the user to enter a value as a C string in the form: xxx,xxx,xxx,xxx,xxx.xx, where x can be any digit. Well, so far here is my attempt. I think the question is, would I have to implement a switch statement for the digits, the comma, and the decimal, so that when a user inputs, let say 52,000.00 the switch statements would read the 1st digit, checks for decimals/commas and if not, proceed to read 2nd digit, and repeat?
Code: #include <iostream> #include <string> int main() { using namespace std; char buffer[256]; char tempBuff[256] = {'
This code is near complete, the only task that is left is allowing the user to input a decimal and then two integers, or automatically using .00 decimal.
The automatic part: /*This is not correct.
printf(".%.2d ", number); */
But that does no good for me. Question: Do I have to create a some sort of while loop again, to allow the user to input a decimal followed by integer?
Code: #include <iostream> #include <cstdlib> using namespace std; int main() { int j , i = 0, k = 0; int number;
Is there a way to know from a Windows service application (running as a local-system) if a specific logged in interactive user account is configured with a roaming profile? I need this to be compatible with Windows XP SP3.
I am looking for direction on what topic I should be reading up on. I am new to C++ and Windows MFC.
This is my real world problem, in the context of the application user. (these term do not refer to OPP concepts)
I want to create shapes (containers) in an application that will respond and collect other objects;
Imagine a Windows frame, containing several 2 dimensional squares. I want to be able to drag and drop marbles into the squares,and have the square retain and display the marbles in the square, in the order that they were dropped in.
How do I create the shapes, and how will the square sense when a marble is over it?
How would I create irregular shapes (a combination of lines and curves) that would be responsive to the marbles?
I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.
Im working on my project for college and i want to know how to add sth similar to a chronometer for user to see how much time have passed while entering some characters using cin.getline function.
I have been trying to finish this code (function) for a while now, but am stuck on the last part. In this code, I prompt the user to select a number of integers and any number of digits and then find the smallest and largest value within these digits. On the next part, I am supposed to determine which of the given digits the smallest and largest are located such that the output should be:
Digit _ can be found in integer number(s): _, _
Here is what I have tried:
Code: int digitSizeLoca() { int userNumInteger; int* iPtr; int* iPtr2; int* iPtr3; int value;
[Code] ....
Seems to do the job, but it always outputs 1, 2...
I'm writing a Windows service using WinAPIs and C++. One of the options is that I need to send the system into sleep after all users are logged out. The log-out command is started from the UI (which can notify my service), the problem is knowing how long it takes for all user accounts to be completely logged out before putting the system to sleep.
I first thought to introduce an artificial delay from the moment when the log-out command is issued and before entering the sleep mode, but in a situation when some user account was configured with a roaming profile, the log-out process may well exceed my delay.
how to know if all user accounts are logged out "for sure"?
I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:
#include <iostream> int main() { using namespace std; int num; int total = 0; int x;
[Code] ....
The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?
What I want to do is create a file that will ask the user to enter his info,n then store it in a text file The screen will ask the user if he wants to update his info. if he says yes then the screen will be cleared and the old info will be printed on the screen. The user will enter his new info that will be stored in a new file. My problem is that once the user finishes entering his input the program just closes D: and the rest of the program won't run.
Code:
int main() { string ans; ofstream Xfile("original.txt"); cout <<"Enter your name and address please"<<endl; cout<<"Press Ctrl+Z+Enter when you are done"<<endl; string name_and_street;
Store the result into an array D of 8 elements. Your program should show the decimal numbers for every binary number. Print screen of 6 answers. This means you should try your program six times with different numbers in every run and show the printed screen result.
And then the Calculator is shown in domainuser1 desktop, but the process is running in domainuser2 account.
When running Spy++ (either wither domainuser1 or domainuser2) to view the calculator window, the Windoe Proc field is shown 'Unavailable' I also try to call GetWindowLong against this window, it will always returns NULL.
I am just wondering if it is possible to retrieve the Window Proc of the window running in a process of another account, is is possible?
I have a dialog control where I am using a slider control. I have handled the notification messages sent by the slider control. When user clicks on the slider, the slider moves in steps. I want to bring the slider directly to the position where user has clicked the mouse. The slider thumb should directly move to the clicked position instead of in steps.
I have to write a program where the user will input integer numbers. How many numbers they enter is unknown, therefor you should use a repetition structure for the input. When the user is done, they will enter -1 to exit.
Create a dynamic array if the size=2( the initial size must be 2) Repeat until user enters -1.
I have to do this without using vectors.
This is what i have, I cannot figure out what to put in main. I was thinking of a do-while?
Code: #include <iostream> using namespace std; void resize(int *[], int); int main() { int *listDyn; int size=2;