Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sample Program to Terminate The Winamp 2.x in Win32

Status
Not open for further replies.

hughLg

Programmer
Feb 18, 2002
136
MY
Code:
/* Created by Dennis C. Development period's from 19 October 2002 to 21 October 2002. This program'll ends the running of Winamp program. */

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>

void dispInvalidOptMess();
void dispMenu();
void endWinamp();
int getCountDown();
int getOption();

int
main()
{
	do {
		dispMenu();
	} while (getOption() != '1');
	return 0;
}

void
dispInvalidOptMess()
{
	printf(&quot;\a\a\nInvalid Option Entered!\n&quot;);
	system(&quot;pause&quot;);
}

void
dispMenu()
{
	system(&quot;cls&quot;);
	puts(&quot;SleepAmp (v 0.0)&quot;);
	puts(&quot;\n[0] Input countdown time&quot;);
	puts(&quot;[1] Return&quot;);
	printf(&quot;\nOption: &quot;);
}

void
endWinamp()
{
	system(&quot;taskkill /im winamp.exe /t&quot;);
}

int
getCountDown()
{
	time_t start_tm, hour, minute, second, second1;
	time_t current_tm, diff_tm;
	struct tm *time_tm;

	fflush(stdin); /* fluch stdin in order to've proper subsequent input. */
	printf(&quot;\n\nRemaining time to sleep the Winamp (hh:mm:ss): &quot;);
	/* check for correctness of time. */
	if ((scanf(&quot;%d:%d:%d&quot;, &hour, &minute, &second) < 3) || (minute > 60) || (second > 60)) {
		puts(&quot;\a\aInvalid Input!&quot;);
		system(&quot;pause&quot;);
		return 0;
	}
	second1 = (second + (minute * 60) + (hour * 60 * 60));
	time(&start_tm);
	while ((diff_tm = (time(¤t_tm) - start_tm)) < second1) {
		/* if <Esc> key was pressed, return to calling function. */
		if (kbhit())
			switch (getch()) {
			case 27:
				return 0;
			case 0: case 224:
				getch();
			}
		/* get remaining time. */
		diff_tm = (second1 - diff_tm);
		time_tm = gmtime(&diff_tm);
		printf(&quot;\r%d:%d:%d remaining...&quot;, time_tm->tm_hour, time_tm->tm_min, time_tm->tm_sec);
	}
	endWinamp();
	return 1;
}

int
getOption()
{
	switch (putch(getch())) {
	default:
		dispInvalidOptMess();
		return 0;
	case 0: case 224:	/* function or extended keys? */
		getch();
		dispInvalidOptMess();
		return 0;
	case '0':
		return getCountDown();
	case '1':
		return '1';
	}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top