📄 monset.c
字号:
//-----------------------------------------------------------------
// Module Name: MonSet.C
// Abstract: Print Monitor Setup Console Program
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include "MonSetfn.h"
#define STREX "MonSet Usage:\nInstall: MonSet \"Wireless Port\""\
" c:\\temp\\WLSMON.DLL\nRemove: MonSet \"Wireless Port\"\n"
#define FMT_NOTFOUND "The Monitor is NOT Found for %s !\n"
#define FMT_INSTALLED "The Monitor is Already Installed for %s !\n"
VOID ShowLastError()
{
LPVOID lpBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpBuf, 0, NULL );
printf("\nError: %s", (LPTSTR)lpBuf);
LocalFree(lpBuf);
}
void main(int argc, char *argv[ ], char *envp[ ])
{
if (argc==2 || argc==3) // valid cmd line with argument
{
int iRet, i;
if (iRet=FindMonitor(argv[1]))
{
LPTSTR szEnvOS;
for(i=0; envp[i]; ++i) // verify NT env var
if (!lstrcmpi(envp[i], "OS=Windows_NT")) break;
if (!envp[i]) // support other OS', if need
{
printf("\nNo NT Environment Variables OS !\n" );
return;
}
szEnvOS ="Windows NT x86"; // now only for x86
if (argc==3) // install option
{
if (iRet==FM_FOUND) // already exists
printf(FMT_INSTALLED, argv[1]);
else // install it with port name, env, dll path
if (InstallMonitor(argv[1], szEnvOS, argv[2]))
printf("OK, Installed %s for %s!",
argv[2], argv[1]);
else
ShowLastError();
}
if (argc==2) // remove option
{
if (iRet==FM_NOTFOUND) // lost
printf(FMT_NOTFOUND, argv[1]);
else // remove it with port name, env
{
printf("Remove the Monitor %s ? (Y/N)", argv[1]);
if ('Y' !=toupper(getche())) return;
if (RemoveMonitor(argv[1], szEnvOS))
printf("\nOK, %s is Removed !", argv[1]);
else
ShowLastError();
}
}
}
else ShowLastError(); // if iRet==FM_ERROR
}
else printf(STREX); // if no argument
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -