Click here to Skip to main content
15,893,722 members
Articles / Programming Languages / C++

Shell extension to make executables as services

Rate me:
Please Sign up or sign in to vote.
3.22/5 (6 votes)
8 Apr 2000 89.3K   1.9K   41  
A 'not-so-simple' shell extension allowing executable to be run as services
#include "WndHelpers.h"

void 
CenterWindow(HWND hWnd)
{
	int cx, cy, dx, dy;
	HDC hDC;
	HWND hDeskWnd;
	RECT rc;

	GetWindowRect(hWnd, &rc);

	hDeskWnd = GetDesktopWindow();
	hDC = GetDC(hDeskWnd);
	cx = GetDeviceCaps(hDC, HORZRES);
	cy = GetDeviceCaps(hDC, VERTRES);
	DeleteDC(hDC);

	dx = rc.right - rc.left;
	dy = rc.bottom - rc.top;
	cx = (cx - dx) / 2;
	cy = (cy - dy) / 2;

	MoveWindow(hWnd, cx, cy, dx, dy, TRUE);
}

void __stdcall
MultipleCBAddStringByDlgId(HWND hwndDlg, int nCtlId, int nStringCount, ...)
{
	register int x;
	va_list marker;

	if(!IsWindow(hwndDlg))
		return;

	va_start(marker, nStringCount);
	for(x = 0; x < nStringCount; x++)
	{
		SendMessage(GetDlgItem(hwndDlg, nCtlId), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)va_arg(marker, LPCTSTR));
	}
	va_end(marker);
}

void
MultipleShowWindowByDlgId(HWND hwndDlg, BOOL fShow, int nCtlIdCount, ...)
{
	register int x;
	va_list marker;

	if(!IsWindow(hwndDlg))
		return;

	va_start(marker, nCtlIdCount);
	for(x = 0; x < nCtlIdCount; x++)
	{
		ShowWindow(GetDlgItem(hwndDlg, (UINT)va_arg(marker, UINT)), fShow ? SW_SHOW : SW_HIDE);
	}
	va_end(marker);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions