C/C++ :: How To Determine If Application Is Already Running On Mac OSX

Dec 18, 2014

I have a service A, and an application B. Service A needs to launch application B only if it's not running currently. This can be easily done in Windows by calling GetExitCodeProcess function. I cannot find an equivalent method for doing so in Linux/Mac.

So my current code says:

system("open /Users/adsmaster/client/client &"); // to launch the application from the service in a new shell

I read that on a Linux-line machine you can use $ cal to get the exit value of the recently run process but I am not sure how can get the exit value of a particular process?

View 1 Replies


ADVERTISEMENT

C# :: Running PowerShell Cmdlets From Application

Feb 26, 2015

I'm fairly new to PowerShell and I'm trying to run this command from my application to return the 25 newest entries in the application event log and save them to a file on my desktop. Here's the code. I get an Common Language Runtime error with no real information.

PowerShell ps = PowerShell.Create();
ps.AddCommand("Get-EventLog");
ps.AddArgument("application");
ps.AddParameter("Newest", 25);
ps.AddScript("Format-List > ~\Desktop\samplelog.txt");
ps.Invoke();

Here is the Method: [URL] ....

Here is the Error: [URL] ....

View 10 Replies View Related

Visual C++ :: Check Whether Application Instance Is Running Or Not

Jan 20, 2014

For my project I need to check whether my application instance is already running or not. I got the following code from Net ..

Code :

HANDLE mutex;
mutex = CreateMutex( NULL, TRUE, _T("MYAPPNAME"));
if ( GetLastError() == ERROR_ALREADY_EXISTS ) {
// There's another instance running. What do you do?
AfxMessageBox(_T("Application Already Exists"));
PostQuitMessage(0);
ExitThread(0);
return;
}

The code works fine .. but the code even works fine , even if I pass any string as a parameter to CreateMutex. E.g.

mutex = CreateMutex( NULL, TRUE, _T("QQQQ"));

How it is working fine ?

View 5 Replies View Related

C Sharp :: Unable To Type Into Text Box While Running The Application?

Mar 24, 2013

actually it is the windows application .When i'm running my program it is not allowing me to enter the data into textboxes means the cursor is not appearing

View 1 Replies View Related

C :: Sending Simulated Keyboard Input Into Running System Application

Nov 26, 2014

I'm trying to simulate a ctrl+ keypress into a running application.

Code:
#include <stdio.h>
int main (void) {
system("/usr/local/bin/rundb");
}

My problem is that the rundb program needs the user to type ctrl-b then s to actually start executing. What is the best way to handle this automatically? Some sort of fork/pipe?

View 3 Replies View Related

C# :: Server Application Using Tcp Protocol And Then Establish Connection With A Client Application

Nov 29, 2014

What happens if I make a server application using tcp protocol and then establish connection with a client application but the server crash and then the client send data. Will the data be lost or the system will continue trying to send it?

View 2 Replies View Related

C# :: How To Start Application And Automatically Pass Input To That Application

May 9, 2012

I want to create an application that starts an application and passes input to that application. I know how to start a process using the classes in System.Diagnostics, but I don't know how to pass data to the process.

For example, and this is just an example, I would like to be able to automatically start an application that requires a username and password and automatically enter the username and password. Of course, that might open the door to security vulnerabilities, but that's not the point of the exercise.

How to implement the functionality I described? Is there a general way to go about doing this or does it depend entirely on the idiosyncrasies of the application in question?

View 2 Replies View Related

C Sharp :: Run Application When Log Off In Console Application

Oct 4, 2012

i have task scheduling application which execute every 30 minute i want to keep this process when system is log off in c# console application

View 2 Replies View Related

C :: Can't Determine Tie Status Of The Game

Nov 12, 2014

I've made an effort for three days to write this code. But, my brain has stopped now. I wrote code to find the status of the game (win, loss or tie). However, I can't determine the tie status of the game. Tie status is the problem

View 5 Replies View Related

C :: How To Determine Length Of Array

Apr 16, 2013

I'm working with arrays that might have NULL bytes in them and I'm wondering how to determine the length of the array or store it somewhere with the array (strlen() won't work because of the NULL, right?).

I've found advice like store the length of the array in the first byte of the array, but since sizeof(size_t) is 8 should I leave the first 8 bytes for the length?

Would it be better do define my own structure which would store the array and its length? What's the usual way these things are handled in practice?

View 7 Replies View Related

C++ :: Determine If A Function Has Been Defined

Apr 8, 2013

I would like to make a handler for input events, but not be required to define all the functions.For example, if I had

void mouseDown(int button,vec2 pos);
void mouseUp(int button,vec2 pos);
static void mouseStateHandle(int button,int state,int x,int y) {
switch(state){
case DOWN:

[code]....

in the 'mouseStateHandle' function? I don't know enough about C++ to be able to come up with a solution.

View 19 Replies View Related

C++ :: Determine Integer In TXT File

Nov 9, 2014

I am making an eVoting program which takes input from .txt file and outputs in the same .txt file. I need to ask the user to enter the candidate they wish to vote and then read the previous tally from the .txt file and add one to it. The problem is determining the numbers in a .txt file and adding one to it.

For example voting_Tally.txt contains:

Bloomberg 1234
Bill De Blasio 6789

How would it be possible to first determine the name and then add one to their tally. For Example:

Bloomberg 1235
Bill De Blasio 6790

View 2 Replies View Related

C++ :: Determine Whether There Is A Collision Between 2 Meshes

Oct 19, 2013

How can I determine whether there is a collision between 2 meshes? I'd just like to see if one mesh is inside another.

View 10 Replies View Related

C/C++ :: Determine That Char Is A Letter

Nov 18, 2014

I need to count how many times letter appears in a text. I know that for default letters from 'a' to 'z' and from 'A' to 'Z' there is an interval. But I need also Lithuanian letters, such as ž,č,ę. I wrote this method: (it accepts char code and checks whether that char is a letter)

bool eilutė::YraRaidė(int kodas)
{
if(kodas >= 'a' && kodas <= 'z') {
return true;

[Code]....

As you can see, a lot of checking in switch statement. I use 256 for this reason to have the same effect as unsigned char. But maybe there is a way to shrink down this method, or use some library?

View 7 Replies View Related

C :: Determine Compiler Version And Which Standard It Uses?

Jul 18, 2013

Is there any code I can use to determine my compiler version and which Standard It uses? I know the following code determine that my compiler followed ANSI But how about a version of that? ****My OS is now Ubuntu

Code:
#include <stdio.h>
int main(void){
printf("File :%s
", __FILE__ );
printf("ANSI :%d
", __STDC__ ); //return 1 if it follow ANSI but version?
return 0;
}

View 3 Replies View Related

C :: Determine If Adversary Pawns Are Captivated

Feb 28, 2013

I am trying to write a simple application that resembles the game "Computer Co", but I am stuck with this problem: If the board is represented by a dimensional array, with what algorithm could I tell if one player's pieces are captivated by the other's? In other words, how can I recognise whether the pieces of one colour form a circle?

View 6 Replies View Related

C :: Determine Minimum Number Of Changes That Can Be Made

Mar 7, 2013

You are given an integer, perhaps a very long long integer, composed of only the digits 1 and/or 2. You have the ability to change a 1 digit into a 2 and a 2 digit into a 1 and must determine the min. number of changes that you can make resulting in no 2 digits remaining in the number that are in a position(in terms of powers of ten) higher than any 1 digit.

example:

2222212 number of changes:1
1111121 1
2211221 3
1122112 2

no negative numbers.

how to get started. Also I'm not allowed to use anything related to arrays or sorting.

View 6 Replies View Related

C++ :: Program To Determine Coin Change

Oct 20, 2013

I have a current assignment for C++ involving us to make a program to determine coin change for example if you input the number 127 you would need 2 half dollars 1quarter and 2 pennies I have no way how to program this.

This is my code that doesn't do what i want it to

#include <iostream>
using namespace std;
int main ( ) {
float change;
int half_dollars, quarters, dimes, nickels, pennies; // declare variables

[Code] ....

View 1 Replies View Related

C++ :: Arrays - Determine Grades At The End Of Semester

Jul 18, 2013

Write a C++ program that can be used to determine grades at the end of the semester. For each student, who is identified by an integer number between 1 and 60, four examination grades must be kept. Additionally, two final grade averages must be computed. The first grade average is simply the average of all four grades. The second grade average is computed by weighting the four grades as follows: the first grade gets a weight of 0.2, the second grade gets a weight of 0.3, the third grade a weight of 0.3, an the fourth grade a weight of 0.2; that is computed as:

0.3*grade1 + 0.2*grade2 + 0.2*grade3 + 0.3*grade4

Using this info, you are to construct a 60X7 two dimensional array, in which the first column used for the student number, the next four columns for the grades, and the last two columns for the computed final grades. The output of the program should be a display of the data in the completed array.

View 8 Replies View Related

C++ :: How To Determine If Two Numbers Differ From A Specific Value

Dec 2, 2014

I have to write a program that use a while loop and that each time around the loop reads two double, prints out the largest, the smallest and if they are equal.

I have no problem with this program but I can't understand how to modify it following the author : Change the program so that it writes out "the numbers are almost equal" after writing out which is the larger and the smaller if the two numbers differ by less than 1.0/100.

for now this is my code :

int main() {
double a = 0;
double b = 0;
while (cin >> a >> b) {
cout << "first number is : " << a << "
second number is : " << b << "

[Code] ....

The problem is that I don't know how to test if the numbers differ by less than 0.01 because my if statement doesn't work in any case. If I enter 2 and 1.99 It doesn't work, why ?

View 4 Replies View Related

C++ :: How To Determine A Special Character In A String

Feb 6, 2015

I have to make an email validation program and i am halfway done. I only have one more problem, consider the ff. example:

Enter email:
myemail.@something.com //this is the input
Invalid //this should be the output

How can i determine if there is a special character near the '@' sign? and vice versa?

View 4 Replies View Related

C/C++ :: Determine Input Type Without Converting

Sep 19, 2014

Originally I had to create a simple integer palindrome program that looped while the user entered 5 digit inputs (entering -1 stopped the loop). I did this using a conversion to string, reading the length to determine if the length was valid, and then reading the string forward and backwards inside of a while loop. (snippet below)

while( digitsEntered != -1)//Allow user to quit by entering -1 to end the loop
{
ostringstream convert;//conversion stream
convert << digitsEntered;//converted text from number goes in the stream
convertedString = convert.str();//store the resulting conversion to convertedString

[Code] ....

The next stage of this program was to do the same thing with strings instead of integers. However, the option to end the loop by entering -1 is still a requirement.

I think the way to do this is to first determining whether the input is a string or an integer, and if it is a string then read it and if it's an integer determine if it's -1. However, whenever I write code to do this, it converts strings to 0 so the string is not stored and cannot be read to determine if it is a palindrome. Is there a way to determine the type of input without converting it into a different type i.e. read string and then keep string or read number and keep number?

View 3 Replies View Related

C++ :: Sentinel Value To Determine Type Of Character

Apr 24, 2014

Write a program that will prompt a user to enter a single character, the prompting will continue till a sentinel value is entered. For each character entered perform the following tests and print out a relevant message if the character passes the test. Print out a default message if the character does not pass any of the tests.

Tests that should be in program: Punctuation, Upper Case, Digit, White Space.

Sample Run: “A”, “a”, “7”, <tab>, “?”, “$”

So far I have the following code done. The problem is that when I run the program, the first character is correctly identified. However, every character afterwards is defined as a whitespace character.

#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
int main() {
char input;
char response;

[Code] .....

View 2 Replies View Related

C/C++ :: Determine Smallest Number Xmin

Jan 21, 2014

In a fashion similar to that in Fig. 3.11(shown below), write a short program to determine the smallest number, xmin, used on the computer you will be employing along with this book. Note that your computer will be unable to reliably distinguish between zero and a quantity that is smaller than this number.

fig311.png

View 2 Replies View Related

C++ :: Determine Roots Of Quadratic Equations?

May 23, 2013

I have given following exercise in my cpp book: Determine the roots of quadratic equations

ax^2 + bx + c = 0

using formula

x = -b +(plus-minus) (root)b^2 - 4ac/2a

i don't now how to write such code...

View 6 Replies View Related

C++ :: Determine If A Templated Class Has A Constructor

Mar 12, 2012

Can I determine if a templated class has a particular constructor, in my case using a string within function to which T is used?

Code:

template<class T>
void MakeObject(std::vector<T>& dataVector)
{
std::string str "con string,Joe,24";
// catch if T has string constructor
T someObject(str); // T someObject should have constructor from string
dataVector.push_back(someObject);
}

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved