diff options
28 files changed, 1524 insertions, 0 deletions
diff --git a/reschange.exe b/reschange.exe Binary files differnew file mode 100755 index 0000000..2599e6e --- /dev/null +++ b/reschange.exe diff --git a/reschange/DisplayUtils.cpp b/reschange/DisplayUtils.cpp new file mode 100644 index 0000000..cccc5af --- /dev/null +++ b/reschange/DisplayUtils.cpp @@ -0,0 +1,141 @@ +#include "stdafx.h"
+#include <stdio.h> +#include "windows.h"
+#include "DisplayUtils.h"
+
+#define MAX_DEVICE_NUMBER 10
+#define WIN2K_MAJOR_BUILD 5
+#define WIN2K_MINOR_BUILD 0
+#define QUMRANET_DEVICE_SIGNATURE L"Red Hat"
+
+//#define DEBUG
+
+BOOL isWin2K()
+{
+ OSVERSIONINFO ver;
+ ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (GetVersionEx(&ver)) {
+ if (WIN2K_MAJOR_BUILD == ver.dwMajorVersion &&
+ WIN2K_MINOR_BUILD == ver.dwMinorVersion) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL isAttached(LPCTSTR DeviceName)
+{ + DEVMODE DevMode;
+ ZeroMemory(&DevMode, sizeof(DEVMODE)); + DevMode.dmSize = sizeof(DEVMODE); + DevMode.dmDriverExtra = 0; + EnumDisplaySettings(DeviceName, ENUM_CURRENT_SETTINGS, &DevMode); + return !!DevMode.dmBitsPerPel; +}
+
+void InitModeStructure(DEVMODE *DevMode, MonitorConfig *MonConfig, BOOL bSetPos)
+{
+ ZeroMemory(DevMode, sizeof(DEVMODE));
+ DevMode->dmSize = sizeof(DEVMODE);
+ if (MonConfig) {
+ DevMode->dmBitsPerPel = MonConfig->dwDepth;
+ DevMode->dmPelsWidth = MonConfig->dwWidth;
+ DevMode->dmPelsHeight = MonConfig->dwHeight;
+ DevMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
+ if (bSetPos) {
+ DevMode->dmPosition.x = MonConfig->dwPosX;
+ DevMode->dmPosition.y = MonConfig->dwPosY;
+ DevMode->dmFields |= DM_POSITION;
+ }
+ } else {
+ //detach monitor
+ DevMode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION;
+ }
+}
+
+BOOL GetQxlDeviceID(CHAR *DeviceKey, DWORD *DeviceID)
+{
+ DWORD dwType = REG_BINARY;
+ DWORD dwSize = sizeof(*DeviceID);
+ BOOL bKeyFound = FALSE;
+ HKEY hKey;
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, strstr(DeviceKey, "System"),
+ 0L, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) {
+ bKeyFound = (RegQueryValueEx(hKey, "QxlDeviceID", NULL, &dwType,
+ (LPBYTE)DeviceID, &dwSize) == ERROR_SUCCESS);
+ RegCloseKey(hKey);
+ }
+ return bKeyFound;
+}
+
+int ChangeResolution(TCHAR *strDevicePNPID, BOOL bAll, BOOL bAttach, BOOL bPosition,
+ int nMons, MonitorConfig *monConfig)
+{
+ DISPLAY_DEVICE displayDevice;
+ DEVMODE DevMode;
+ HDESK hdeskInput;
+ HDESK hdeskCurrent;
+ BOOL attached;
+ int monsCount = 0;
+ int totalWidth = 0;
+ int ret;
+
+ hdeskCurrent = GetThreadDesktop(GetCurrentThreadId());
+ if (hdeskCurrent == NULL)
+ return 0;
+
+ hdeskInput = OpenInputDesktop(0, FALSE, MAXIMUM_ALLOWED);
+ if (hdeskInput == NULL)
+ return 0;
+
+ if (!SetThreadDesktop(hdeskInput)) {
+ CloseDesktop(hdeskInput);
+ return 0;
+ }
+
+ for (DWORD dwI = 0; dwI < MAX_DEVICE_NUMBER; dwI++) {
+ displayDevice.cb = sizeof(DISPLAY_DEVICE);
+ if (EnumDisplayDevices(NULL, dwI, &displayDevice, 0)) {
+ printf("id=%s\n", displayDevice.DeviceID); + if (displayDevice.DeviceID && displayDevice.DeviceID[0] &&
+ (bAll || _tcsstr(displayDevice.DeviceID, strDevicePNPID))) {
+ if (isWin2K()) {
+ ChangeDisplaySettings(NULL, 0);
+ }
+ DWORD dwDeviceID = 0;
+ if (!bAll && !GetQxlDeviceID(displayDevice.DeviceKey, &dwDeviceID)) {
+#ifdef DEBUG
+ dwDeviceID = monsCount;
+#else
+ continue;
+#endif
+ }
+ if ((int)dwDeviceID < nMons) {
+ attached = isAttached(displayDevice.DeviceName);
+ InitModeStructure(&DevMode, &monConfig[dwDeviceID], (attached && !bPosition) ? FALSE : bAttach);
+ if (bAll) {
+ DevMode.dmPosition.x = monsCount * DevMode.dmPelsWidth;
+ } else if (bAttach && !attached && !bPosition) {
+ DevMode.dmPosition.x = totalWidth;
+ }
+ totalWidth += monConfig[dwDeviceID].dwWidth;
+ } else {
+ InitModeStructure(&DevMode, NULL, FALSE);
+ }
+ ret = ChangeDisplaySettingsEx(displayDevice.DeviceName, &DevMode,
+ NULL, CDS_RESET | CDS_GLOBAL |
+ CDS_UPDATEREGISTRY, NULL);
+ if (ret == DISP_CHANGE_SUCCESSFUL) {
+ monsCount++;
+ }
+ }
+ }
+ }
+ if (monsCount) {
+ ChangeDisplaySettings(NULL, 0);
+ }
+ SetThreadDesktop(hdeskCurrent);
+ CloseDesktop(hdeskInput);
+ return monsCount;
+}
diff --git a/reschange/DisplayUtils.h b/reschange/DisplayUtils.h new file mode 100644 index 0000000..4b1e408 --- /dev/null +++ b/reschange/DisplayUtils.h @@ -0,0 +1,15 @@ +#ifndef DISPLAY_UTILS_H
+#define DISPLAY_UTILS_H
+
+typedef struct MonitorConfig {
+ DWORD dwWidth;
+ DWORD dwHeight;
+ DWORD dwDepth;
+ LONG dwPosX;
+ LONG dwPosY;
+} MonitorConfig;
+
+int ChangeResolution(TCHAR * strDevicePNPID, BOOL bAll, BOOL bAttach, BOOL bPosition,
+ int nMons, MonitorConfig *monConfig);
+
+#endif //DISPLAY_UTILS_H
diff --git a/reschange/GRXDeviceEnum/GRXDeviceEnum.cpp b/reschange/GRXDeviceEnum/GRXDeviceEnum.cpp new file mode 100644 index 0000000..f1a60b6 --- /dev/null +++ b/reschange/GRXDeviceEnum/GRXDeviceEnum.cpp @@ -0,0 +1,58 @@ +// GRXDeviceEnum.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include "windows.h"
+
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ //Get device info
+ DISPLAY_DEVICE displayDevice;
+ DEVMODE DevMode;
+ DWORD dwI = 0;
+
+ displayDevice.cb = sizeof(DISPLAY_DEVICE);
+
+ while(EnumDisplayDevices(NULL, dwI, &displayDevice, 0))
+ {
+ printf("Device number: %d\n",dwI);
+ printf("Device name: %ws\n",displayDevice.DeviceName);
+ printf("DeviceString: %ws\n",displayDevice.DeviceString);
+ printf("DeviceID: %ws\n",displayDevice.DeviceID);
+ printf("StateFlags: 0x%x\n",displayDevice.StateFlags);
+
+ /*
+ Flags meaning:
+ #define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001
+ #define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002
+ #define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004
+ #define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008
+ #define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010
+ #define DISPLAY_DEVICE_REMOVABLE 0x00000020
+ #define DISPLAY_DEVICE_MODESPRUNED 0x08000000
+ #define DISPLAY_DEVICE_REMOTE 0x04000000
+ #define DISPLAY_DEVICE_DISCONNECT 0x02000000 */
+
+ printf("Graphic modes:\n");
+ DWORD dwMode = 0;
+ while(EnumDisplaySettings(displayDevice.DeviceName, dwMode++, &DevMode))
+ {
+ printf("%04d: %dX%d - %dBits Freq %d Flags 0x%x \n",
+ dwMode,
+ DevMode.dmPelsWidth,
+ DevMode.dmPelsHeight,
+ DevMode.dmBitsPerPel,
+ DevMode.dmDisplayFrequency,
+ DevMode.dmDisplayFlags
+ );
+ }
+
+ printf("----------------------------------------------------\n");
+ displayDevice.cb = sizeof(DISPLAY_DEVICE);
+ dwI++;
+ }
+
+ return 0;
+}
+
diff --git a/reschange/GRXDeviceEnum/GRXDeviceEnum.sln b/reschange/GRXDeviceEnum/GRXDeviceEnum.sln new file mode 100644 index 0000000..df5ac96 --- /dev/null +++ b/reschange/GRXDeviceEnum/GRXDeviceEnum.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GRXDeviceEnum", "GRXDeviceEnum.vcproj", "{6009552B-9565-420E-9158-5118A4E85DF5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6009552B-9565-420E-9158-5118A4E85DF5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6009552B-9565-420E-9158-5118A4E85DF5}.Debug|Win32.Build.0 = Debug|Win32
+ {6009552B-9565-420E-9158-5118A4E85DF5}.Release|Win32.ActiveCfg = Release|Win32
+ {6009552B-9565-420E-9158-5118A4E85DF5}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/reschange/GRXDeviceEnum/GRXDeviceEnum.vcproj b/reschange/GRXDeviceEnum/GRXDeviceEnum.vcproj new file mode 100644 index 0000000..a3ad8cc --- /dev/null +++ b/reschange/GRXDeviceEnum/GRXDeviceEnum.vcproj @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="GRXDeviceEnum"
+ ProjectGUID="{6009552B-9565-420E-9158-5118A4E85DF5}"
+ RootNamespace="GRXDeviceEnum"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="2"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\GRXDeviceEnum.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/reschange/GRXDeviceEnum/stdafx.cpp b/reschange/GRXDeviceEnum/stdafx.cpp new file mode 100644 index 0000000..9c83db0 --- /dev/null +++ b/reschange/GRXDeviceEnum/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes
+// GRXDeviceEnum.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/reschange/GRXDeviceEnum/stdafx.h b/reschange/GRXDeviceEnum/stdafx.h new file mode 100644 index 0000000..bdabbfb --- /dev/null +++ b/reschange/GRXDeviceEnum/stdafx.h @@ -0,0 +1,17 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#include <stdio.h>
+#include <tchar.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/reschange/Makefile b/reschange/Makefile new file mode 100644 index 0000000..be3d944 --- /dev/null +++ b/reschange/Makefile @@ -0,0 +1,23 @@ +CC=cl.exe +CXX=cl.exe + +ROOT=c:\\WinDDK\\7600.16385.1 +CXXFLAGS=/I$(ROOT)\\inc\\crt /I$(ROOT)\\inc\\api + +all: reschange.exe + +objs=my_getopt.obj DisplayUtils.obj reschange.obj stdafx.obj + +reschange.exe: $(objs) + link.exe /libpath:$(ROOT)\\lib\\Crt\\i386 /libpath:$(ROOT)\\lib\\wxp\\i386 $(objs) user32.lib advapi32.lib /out:reschange.exe /subsystem:console + +%.obj: %.cpp + $(CXX) /c $(CXXFLAGS) $< + +%.obj: %.c + $(CXX) /c $(CXXFLAGS) $< + +.PHONY: clean + +clean: + rm -f reschange.exe *.obj diff --git a/reschange/change1.bat b/reschange/change1.bat new file mode 100644 index 0000000..230e2f6 --- /dev/null +++ b/reschange/change1.bat @@ -0,0 +1,7 @@ +@echo off +rem do many resolution changes for a single monitor +reschange -mon 800,600,32,0,0 +reschange -mon 600,800,32,0,0 +reschange -mon 1024,768,32,0,0 +reschange -mon 768,1024,32,0,0 +reschange -mon 1024,768,32,0,0 diff --git a/reschange/change2.bat b/reschange/change2.bat new file mode 100644 index 0000000..373a612 --- /dev/null +++ b/reschange/change2.bat @@ -0,0 +1,5 @@ +rem this enables/disables the second monitor +reschange -attach -mon 1024,768,32,0,0 -mon 800,600,32,1024,0 +reschange -attach -mon 1024,768,32,0,0 +reschange -attach -mon 1024,768,32,0,0 -mon 800,600,32,1024,0 +reschange -attach -mon 1024,768,32,0,0 diff --git a/reschange/enable_second.bat b/reschange/enable_second.bat new file mode 100755 index 0000000..9ef759f --- /dev/null +++ b/reschange/enable_second.bat @@ -0,0 +1,2 @@ + +reschange -attach -mon 1024,768,32,0,0 -mon 800,600,32,1024,0
\ No newline at end of file diff --git a/reschange/getopt.h b/reschange/getopt.h new file mode 100755 index 0000000..5f08ccb --- /dev/null +++ b/reschange/getopt.h @@ -0,0 +1,56 @@ +/* + * getopt.h - cpp wrapper for my_getopt to make it look like getopt. + * Copyright 1997, 2000, 2001, 2002, Benjamin Sittler + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef MY_WRAPPER_GETOPT_H_INCLUDED +#define MY_WRAPPER_GETOPT_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +#include "my_getopt.h" + +#undef getopt +#define getopt my_getopt +#undef getopt_long +#define getopt_long my_getopt_long +#undef getopt_long_only +#define getopt_long_only my_getopt_long_only +#undef _getopt_internal +#define _getopt_internal _my_getopt_internal +#undef opterr +#define opterr my_opterr +#undef optind +#define optind my_optind +#undef optopt +#define optopt my_optopt +#undef optarg +#define optarg my_optarg + +#ifdef __cplusplus +} +#endif + +#endif /* MY_WRAPPER_GETOPT_H_INCLUDED */ diff --git a/reschange/my_getopt.c b/reschange/my_getopt.c new file mode 100755 index 0000000..5e9c214 --- /dev/null +++ b/reschange/my_getopt.c @@ -0,0 +1,281 @@ +/* + * my_getopt.c - my re-implementation of getopt. + * Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "my_getopt.h" + +int my_optind=1, my_opterr=1, my_optopt=0; +char *my_optarg=0; + +/* reset argument parser to start-up values */ +int my_getopt_reset(void) +{ + my_optind = 1; + my_opterr = 1; + my_optopt = 0; + my_optarg = 0; + return 0; +} + +/* this is the plain old UNIX getopt, with GNU-style extensions. */ +/* if you're porting some piece of UNIX software, this is all you need. */ +/* this supports GNU-style permution and optional arguments */ + +int my_getopt(int argc, char * argv[], const char *opts) +{ + static int charind=0; + const char *s; + char mode, colon_mode; + int off = 0, opt = -1; + + if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+'; + else { + if((colon_mode = *opts) == ':') off ++; + if(((mode = opts[off]) == '+') || (mode == '-')) { + off++; + if((colon_mode != ':') && ((colon_mode = opts[off]) == ':')) + off ++; + } + } + my_optarg = 0; + if(charind) { + my_optopt = argv[my_optind][charind]; + for(s=opts+off; *s; s++) if(my_optopt == *s) { + charind++; + if((*(++s) == ':') || ((my_optopt == 'W') && (*s == ';'))) { + if(argv[my_optind][charind]) { + my_optarg = &(argv[my_optind++][charind]); + charind = 0; + } else if(*(++s) != ':') { + charind = 0; + if(++my_optind >= argc) { + if(my_opterr) fprintf(stderr, + "%s: option requires an argument -- %c\n", + argv[0], my_optopt); + opt = (colon_mode == ':') ? ':' : '?'; + goto my_getopt_ok; + } + my_optarg = argv[my_optind++]; + } + } + opt = my_optopt; + goto my_getopt_ok; + } + if(my_opterr) fprintf(stderr, + "%s: illegal option -- %c\n", + argv[0], my_optopt); + opt = '?'; + if(argv[my_optind][++charind] == '\0') { + my_optind++; + charind = 0; + } + my_getopt_ok: + if(charind && ! argv[my_optind][charind]) { + my_optind++; + charind = 0; + } + } else if((my_optind >= argc) || + ((argv[my_optind][0] == '-') && + (argv[my_optind][1] == '-') && + (argv[my_optind][2] == '\0'))) { + my_optind++; + opt = -1; + } else if((argv[my_optind][0] != '-') || + (argv[my_optind][1] == '\0')) { + char *tmp; + int i, j, k; + + if(mode == '+') opt = -1; + else if(mode == '-') { + my_optarg = argv[my_optind++]; + charind = 0; + opt = 1; + } else { + for(i=j=my_optind; i<argc; i++) if((argv[i][0] == '-') && + (argv[i][1] != '\0')) { + my_optind=i; + opt=my_getopt(argc, argv, opts); + while(i > j) { + tmp=argv[--i]; + for(k=i; k+1<my_optind; k++) argv[k]=argv[k+1]; + argv[--my_optind]=tmp; + } + break; + } + if(i == argc) opt = -1; + } + } else { + charind++; + opt = my_getopt(argc, argv, opts); + } + if (my_optind > argc) my_optind = argc; + return opt; +} + +/* this is the extended getopt_long{,_only}, with some GNU-like + * extensions. Implements _getopt_internal in case any programs + * expecting GNU libc getopt call it. + */ + +int _my_getopt_internal(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind, + int long_only) +{ + char mode, colon_mode = *shortopts; + int shortoff = 0, opt = -1; + + if(getenv("POSIXLY_CORRECT")) colon_mode = mode = '+'; + else { + if((colon_mode = *shortopts) == ':') shortoff ++; + if(((mode = shortopts[shortoff]) == '+') || (mode == '-')) { + shortoff++; + if((colon_mode != ':') && ((colon_mode = shortopts[shortoff]) == ':')) + shortoff ++; + } + } + my_optarg = 0; + if((my_optind >= argc) || + ((argv[my_optind][0] == '-') && + (argv[my_optind][1] == '-') && + (argv[my_optind][2] == '\0'))) { + my_optind++; + opt = -1; + } else if((argv[my_optind][0] != '-') || + (argv[my_optind][1] == '\0')) { + char *tmp; + int i, j, k; + + opt = -1; + if(mode == '+') return -1; + else if(mode == '-') { + my_optarg = argv[my_optind++]; + return 1; + } + for(i=j=my_optind; i<argc; i++) if((argv[i][0] == '-') && + (argv[i][1] != '\0')) { + my_optind=i; + opt=_my_getopt_internal(argc, argv, shortopts, + longopts, longind, + long_only); + while(i > j) { + tmp=argv[--i]; + for(k=i; k+1<my_optind; k++) + argv[k]=argv[k+1]; + argv[--my_optind]=tmp; + } + break; + } + } else if((!long_only) && (argv[my_optind][1] != '-')) + opt = my_getopt(argc, argv, shortopts); + else { + int charind, offset; + int found = 0, ind, hits = 0; + + if(((my_optopt = argv[my_optind][1]) != '-') && ! argv[my_optind][2]) { + int c; + + ind = shortoff; + while((c = shortopts[ind++])) { + if(((shortopts[ind] == ':') || + ((c == 'W') && (shortopts[ind] == ';'))) && + (shortopts[++ind] == ':')) + ind ++; + if(my_optopt == c) return my_getopt(argc, argv, shortopts); + } + } + offset = 2 - (argv[my_optind][1] != '-'); + for(charind = offset; + (argv[my_optind][charind] != '\0') && + (argv[my_optind][charind] != '='); + charind++); + for(ind = 0; longopts[ind].name && !hits; ind++) + if((strlen(longopts[ind].name) == (size_t) (charind - offset)) && + (strncmp(longopts[ind].name, + argv[my_optind] + offset, charind - offset) == 0)) + found = ind, hits++; + if(!hits) for(ind = 0; longopts[ind].name; ind++) + if(strncmp(longopts[ind].name, + argv[my_optind] + offset, charind - offset) == 0) + found = ind, hits++; + if(hits == 1) { + opt = 0; + + if(argv[my_optind][charind] == '=') { + if(longopts[found].has_arg == 0) { + opt = '?'; + if(my_opterr) fprintf(stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], longopts[found].name); + } else { + my_optarg = argv[my_optind] + ++charind; + charind = 0; + } + } else if(longopts[found].has_arg == 1) { + if(++my_optind >= argc) { + opt = (colon_mode == ':') ? ':' : '?'; + if(my_opterr) fprintf(stderr, + "%s: option `--%s' requires an argument\n", + argv[0], longopts[found].name); + } else my_optarg = argv[my_optind]; + } + if(!opt) { + if (longind) *longind = found; + if(!longopts[found].flag) opt = longopts[found].val; + else *(longopts[found].flag) = longopts[found].val; + } + my_optind++; + } else if(!hits) { + if(offset == 1) opt = my_getopt(argc, argv, shortopts); + else { + opt = '?'; + if(my_opterr) fprintf(stderr, + "%s: unrecognized option `%s'\n", + argv[0], argv[my_optind++]); + } + } else { + opt = '?'; + if(my_opterr) fprintf(stderr, + "%s: option `%s' is ambiguous\n", + argv[0], argv[my_optind++]); + } + } + if (my_optind > argc) my_optind = argc; + return opt; +} + +int my_getopt_long(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind) +{ + return _my_getopt_internal(argc, argv, shortopts, longopts, longind, 0); +} + +int my_getopt_long_only(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind) +{ + return _my_getopt_internal(argc, argv, shortopts, longopts, longind, 1); +} diff --git a/reschange/my_getopt.h b/reschange/my_getopt.h new file mode 100755 index 0000000..2c1dd66 --- /dev/null +++ b/reschange/my_getopt.h @@ -0,0 +1,72 @@ +/* + * my_getopt.h - interface to my re-implementation of getopt. + * Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef MY_GETOPT_H_INCLUDED +#define MY_GETOPT_H_INCLUDED + +#ifdef __cplusplus +extern "C" { +#endif + +/* reset argument parser to start-up values */ +extern int my_getopt_reset(void); + +/* UNIX-style short-argument parser */ +extern int my_getopt(int argc, char * argv[], const char *opts); + +extern int my_optind, my_opterr, my_optopt; +extern char *my_optarg; + +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; + +/* human-readable values for has_arg */ +#undef no_argument +#define no_argument 0 +#undef required_argument +#define required_argument 1 +#undef optional_argument +#define optional_argument 2 + +/* GNU-style long-argument parsers */ +extern int my_getopt_long(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind); + +extern int my_getopt_long_only(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind); + +extern int _my_getopt_internal(int argc, char * argv[], const char *shortopts, + const struct option *longopts, int *longind, + int long_only); + +#ifdef __cplusplus +} +#endif + +#endif /* MY_GETOPT_H_INCLUDED */ diff --git a/reschange/reschange.cpp b/reschange/reschange.cpp new file mode 100644 index 0000000..991071c --- /dev/null +++ b/reschange/reschange.cpp @@ -0,0 +1,107 @@ +// reschange.cpp : Defines the entry point for the application.
+//
+
+#include "stdafx.h"
+#include <stdio.h> +#include "reschange.h"
+#include "DisplayUtils.h"
+#include "getopt.h"
+#include "stdio.h"
+
+//Default video mode values
+#define DEFAULT_VIDEO_WIDTH 800
+#define DEFAULT_VIDEO_HEIGHT 600
+#define DEFAULT_VIDEO_BITS 32
+#define DEFAULT_VIDEO_ATTACH FALSE
+
+#define MAX_MONS 4
+
+//Usage: reschange [-all] [-attach] [-devid=prefix] [-mon=width,height,depth,xpos,ypos (1-4 mons)]
+//Options:
+//-all set all monitors to the first mon setting.
+//-attach attach given monitors and detach the rest, otherwise ignore attachment state.
+//-devid prefix of the relevant devices.
+//-mon monitor display settings. can appear up to 4 times, one for each monitor.
+// the rest of the monitors are ignored/detached according to [-attach].
+//-pos use given monitors positions.
+
+//------------------------------------------------------------------------------
+//
+// PNP ID of the device is passed though command line
+// 1. In case of compatible PNP ID (partial PNP ID) the mode will be set for all
+// the devices matched
+// 2. In case of an empty command line (or using "all" as PNP ID) - the mode for
+// all the devices will be changed
+//------------------------------------------------------------------------------
+
+int main(int argc, char **argv) +{
+ struct option longopts[] = {
+ {"all", no_argument, 0, 0},
+ {"attach", no_argument, 0, 0},
+ {"devid", required_argument, 0, 0},
+ {"mon", required_argument, 0, 0},
+ {"install", no_argument, 0, 0},
+ {"pos", no_argument, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ MonitorConfig mons[MAX_MONS];
+ BOOL all = FALSE;
+ BOOL attach = FALSE;
+ BOOL install = FALSE;
+ BOOL position = FALSE;
+ char ignored, *devid = NULL;
+ int opt, longind = 0;
+ int nmons = 0;
+ int nRetValue = 0;
+
+ printf("reschange\n"); + while ((opt = my_getopt_long_only(argc, argv, "", longopts, &longind)) != -1) {
+ switch (longind) {
+ case 0: /* -all */
+ all = TRUE;
+ break;
+ case 1: /* -attach */
+ attach = TRUE;
+ break;
+ case 2: /* -devid */
+ devid = optarg;
+ break;
+ case 3: /* -mon */
+ if (nmons == MAX_MONS) { + return -1; + } + if (optarg) {
+ if (sscanf_s(optarg, "%d,%d,%d,%d,%d,%c", &mons[nmons].dwWidth, + &mons[nmons].dwHeight, &mons[nmons].dwDepth, + &mons[nmons].dwPosX, &mons[nmons].dwPosY, + &ignored) == 5) { + nmons++; + } else { + return -2; + } + } + break;
+ case 4: /* -install */
+ install = TRUE;
+ break;
+ case 5: /* -pos */
+ position = TRUE;
+ break;
+ }
+ }
+ if (nmons == 0) {
+ mons[0].dwWidth = DEFAULT_VIDEO_WIDTH; + mons[0].dwHeight = DEFAULT_VIDEO_HEIGHT; + mons[0].dwDepth = DEFAULT_VIDEO_BITS; + mons[0].dwPosX = 0;
+ mons[0].dwPosY = 0;
+ nmons = 1;
+ all = TRUE;
+ }
+
+
+ nRetValue = ChangeResolution(devid ? devid : "", all, attach, position, nmons, mons);
+ return (install) ? 0 : nRetValue;
+}
diff --git a/reschange/reschange.h b/reschange/reschange.h new file mode 100644 index 0000000..e60f2eb --- /dev/null +++ b/reschange/reschange.h @@ -0,0 +1,3 @@ +#pragma once
+
+#include "resource.h"
diff --git a/reschange/reschange.ico b/reschange/reschange.ico Binary files differnew file mode 100644 index 0000000..eb47357 --- /dev/null +++ b/reschange/reschange.ico diff --git a/reschange/reschange.rc b/reschange/reschange.rc new file mode 100644 index 0000000..161f882 --- /dev/null +++ b/reschange/reschange.rc @@ -0,0 +1,119 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_RESCHANGE ICON "reschange.ico"
+IDI_SMALL ICON "small.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_RESCHANGE MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "E&xit", IDM_EXIT
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&About ...", IDM_ABOUT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_RESCHANGE ACCELERATORS
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE
+BEGIN
+ IDS_APP_TITLE "reschange"
+ IDC_RESCHANGE "RESCHANGE"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/reschange/reschange.sln b/reschange/reschange.sln new file mode 100644 index 0000000..67c666b --- /dev/null +++ b/reschange/reschange.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reschange", "reschange.vcproj", "{D9BBF385-F4D9-4922-A477-3B236618D0D0}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D9BBF385-F4D9-4922-A477-3B236618D0D0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D9BBF385-F4D9-4922-A477-3B236618D0D0}.Debug|Win32.Build.0 = Debug|Win32
+ {D9BBF385-F4D9-4922-A477-3B236618D0D0}.Release|Win32.ActiveCfg = Release|Win32
+ {D9BBF385-F4D9-4922-A477-3B236618D0D0}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/reschange/reschange.vcproj b/reschange/reschange.vcproj new file mode 100644 index 0000000..7fc4fb3 --- /dev/null +++ b/reschange/reschange.vcproj @@ -0,0 +1,254 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="reschange"
+ ProjectGUID="{D9BBF385-F4D9-4922-A477-3B236618D0D0}"
+ RootNamespace="reschange"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(REDC_BUILD_DIR)$(ConfigurationName)"
+ IntermediateDirectory="$(REDC_BUILD_DIR)$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""..\..\..\common\win\my_getopt-1.5""
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="0"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""..\..\..\common\win\my_getopt-1.5""
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\DisplayUtils.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\common\win\my_getopt-1.5\my_getopt.c"
+ >
+ </File>
+ <File
+ RelativePath=".\reschange.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\DisplayUtils.h"
+ >
+ </File>
+ <File
+ RelativePath=".\reschange.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\reschange.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\reschange.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\small.ico"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/reschange/resource.h b/reschange/resource.h new file mode 100644 index 0000000..d7bbc55 --- /dev/null +++ b/reschange/resource.h @@ -0,0 +1,25 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by reschange.rc
+//
+#define IDD_RESCHANGE_DIALOG 102
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDM_EXIT 105
+#define IDI_RESCHANGE 107
+#define IDI_SMALL 108
+#define IDC_RESCHANGE 109
+#define IDR_MAINFRAME 128
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/reschange/small.ico b/reschange/small.ico Binary files differnew file mode 100644 index 0000000..eb47357 --- /dev/null +++ b/reschange/small.ico diff --git a/reschange/stdafx.cpp b/reschange/stdafx.cpp new file mode 100644 index 0000000..f1fec69 --- /dev/null +++ b/reschange/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes
+// reschange.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/reschange/stdafx.h b/reschange/stdafx.h new file mode 100644 index 0000000..5df7bbe --- /dev/null +++ b/reschange/stdafx.h @@ -0,0 +1,37 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Allow use of features specific to Windows XP or later.
+#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
+#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
+#endif
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+
+// TODO: reference additional headers your program requires here
diff --git a/suspend.exe b/suspend.exe Binary files differnew file mode 100755 index 0000000..fac8804 --- /dev/null +++ b/suspend.exe diff --git a/suspend/makesuspend.bat b/suspend/makesuspend.bat new file mode 100755 index 0000000..21d677d --- /dev/null +++ b/suspend/makesuspend.bat @@ -0,0 +1,3 @@ +set ROOT=c:\winddk\7600.16385.0
+cl suspend.c /c /I%ROOT%\inc\crt
+link /libpath:%ROOT%\lib\Crt\i386 /libpath:%ROOT%\lib\wxp\i386 powrprof.lib suspend.obj
diff --git a/suspend/suspend.c b/suspend/suspend.c new file mode 100755 index 0000000..4fbb91f --- /dev/null +++ b/suspend/suspend.c @@ -0,0 +1,18 @@ +#include <stdio.h>
+#include <windows.h>
+//#define _X86_
+//#include <windef.h>
+//#include <winnt.h>
+#include <powrprof.h>
+
+int main(int argc, char **argv)
+{
+ if (argc == 1) {
+ printf("Standby\n");
+ SetSuspendState(FALSE, FALSE, FALSE);
+ } else {
+ printf("Hibernate\n");
+ SetSuspendState(TRUE, FALSE, FALSE);
+ }
+ return 0;
+}
|