invisible

This is a discussion on invisible within the Windows Programming forums, part of the Platform Specific Boards category; i want to make a program which calculates the time for which a computer is logged on...........can anyone tell me ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    11

    invisible

    i want to make a program which calculates the time for which a computer is logged on...........can anyone tell me how to make a program which can actually run in invisible mode

  2. #2
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    i want to make a program which calculates the time for which a computer is logged on
    Platform specific. What OS are you using?

    can anyone tell me how to make a program which can actually run in invisible mode
    What do you mean by invisible mode? Not having a user interface?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    11
    i am using windows xp
    yes i mean that the user wouldnt be able to see the file running

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Well you can simply have a counter run on start up and log the time to a file on shut down... Check MSDN for some Windows code, otherwise, try the Windows forum here.

    As for invisible mode... even if I knew I probably wouldn't post it as it's potentially malicious.
    Sent from my iPadŽ

  5. #5
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    For log on time, you should use an API function which I don't remember but others will help you.
    For being invisible, simple, if you don't make a window for your application, it will be invisible. But for some kind of applications it is better to make a service.

    [EDIT]
    For being invisible even in processes list, it is a hacking and is forbidden, sorry.
    Last edited by siavoshkc; 09-15-2006 at 04:05 AM.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  6. #6
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    No need to make any invisible windows. Just ask the OS how long it's been up:

    http://msdn.microsoft.com/library/de...ttickcount.asp

    One caveat, after about 49 days it rolls over to zero.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  7. #7
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Here's something that I've used in past projects. You can remotely query the total uptime of a computer.
    Code:
    #pragma comment( lib, "pdh.lib" )   // Search For pdh.lib while linking
    #pragma comment( lib, "user32.lib" )   // Search For user32.lib while linking
    
    #include <windows.h>
    #include <pdh.h>
    #include <pdhmsg.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char *GetWSUptime(char *szComputerName )
    {
    	PDH_STATUS  status;
    	HQUERY      perfQuery;
    	HCOUNTER    uptimeCounter;
    	char static szReturnBuffer[128];
    	char  uptimeCounterPath[1024] = {0};
    	PDH_FMT_COUNTERVALUE uptimeValue;
    	DWORD days, hours, minutes, seconds;
    
    	//
    	// Create a PDH query
    	//
    	if( PdhOpenQuery( NULL, 0, &perfQuery ) != ERROR_SUCCESS )
    	{
    		return NULL;
    	}
    	//
    	// Associate the uptime counter with the query
    	//
    	wsprintf( uptimeCounterPath, "\\\\%s\\System\\System Up Time", szComputerName );
    	status = PdhAddCounter( perfQuery, uptimeCounterPath,
    		0, &uptimeCounter );
    	if( status != ERROR_SUCCESS )
    	{
    		return NULL;
    	}
    	//
    	// Snapshot the counter value
    	//
    	status = PdhCollectQueryData( perfQuery );
    	if( status != ERROR_SUCCESS )
    	{
    		return NULL;
    	}
    	//
    	// Get the formatted counter value
    	//
    	status = PdhGetFormattedCounterValue( uptimeCounter, PDH_FMT_LARGE , NULL, &uptimeValue );
    	if( status != ERROR_SUCCESS )
    	{
    		return NULL;
    	}
    	//
    	// Close the query
    	//
    	PdhCloseQuery( &perfQuery );
    
    	days  =  (DWORD) (uptimeValue.largeValue / (3600*24));
    	hours  = (DWORD) (uptimeValue.largeValue % (3600*24) / 3600);
    	minutes =  (DWORD) (uptimeValue.largeValue % 3600) / 60;
    	seconds  = (DWORD) (uptimeValue.largeValue % 60);
    	memset(szReturnBuffer, 0, sizeof szReturnBuffer);
    	sprintf(szReturnBuffer, " %d Days, %d Hours, %d Minutes", days, hours,minutes);
    	return (char *)szReturnBuffer;
    }
    
    int main(void)
    {
    	printf("system up time %s\n",GetWSUptime("MyComp"));       
    	return 0;
    }

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    11

    windows.h

    i have seen people using a header file named "windows.h"
    well........my c++ doesnt seem to be able to include it.....why??

  9. #9
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    You should include windows.h by
    Code:
    #include<windows.h>
    to be able to write a Windows application. Search your hard disk to find that file.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Invisible Console
    By gavra in forum C Programming
    Replies: 6
    Last Post: 08-26-2008, 07:39 AM
  2. The Invisible Child Window
    By SMurf in forum Windows Programming
    Replies: 0
    Last Post: 03-19-2006, 06:25 AM
  3. Invisible process ( BCPPB 5.0 )
    By MiraX33 in forum C++ Programming
    Replies: 8
    Last Post: 10-19-2005, 12:30 AM
  4. Invisible window
    By krappykoder in forum Windows Programming
    Replies: 7
    Last Post: 10-16-2003, 07:52 PM
  5. Using System(), but invisible?
    By xTrinity in forum C++ Programming
    Replies: 7
    Last Post: 08-14-2003, 02:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21