📄 dllmain.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
dllmain.cpp
--*/
#ifndef UNDER_CE
#include "wchar.h"
#endif
#include "dllmain.h"
#include "imcf.h"
#include <ole2.h>
DWORD g_dwObjectCount;
HINSTANCE g_hInstDll = NULL;
STDAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv )
{
HRESULT hr;
CClassFactory *pClassFactory = new CClassFactory( rclsid );
if( pClassFactory ) {
hr = pClassFactory->QueryInterface( riid, ppv );
RELEASE( pClassFactory );
return hr;
}
return E_OUTOFMEMORY;
}
STDAPI DllCanUnloadNow(void)
{
if(!g_dwObjectCount)
{
return NOERROR;
}
return S_FALSE;
}
BOOL WINAPI DllMain(HANDLE hInstDll, DWORD fdwReason, LPVOID pvReserved)
{
if( DLL_PROCESS_ATTACH == fdwReason )
{
g_hInstDll = (HINSTANCE) hInstDll;
}
return TRUE;
}
#define CLSID TEXT("CLSID\\{0CBEA010-F68E-11D1-8C63-0060977B4593}")
#define DISPLAYNAME TEXT("Japanese Multibox Input")
#define EXEPATH TEXT("c:\\nt\\system32\\multibox.dll")
#define STRINGONE TEXT("1")
#define ICONNAME TEXT("c:\\nt\\system32\\multibox.dll,0")
STDAPI DllRegisterServer()
{
HKEY hkGUID;
HKEY hkReg;
DWORD dwHow;
// First, create the base key for the OLE object under clsid
if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT, CLSID, 0, TEXT("REG_SZ"), 0, KEY_WRITE, NULL, &hkGUID, &dwHow))
{
OutputDebugString(TEXT("Failed to create the guid key under CLSID"));
return E_FAIL;
}
// Now set the named value under this key
if (ERROR_SUCCESS != RegSetValueEx(hkGUID, NULL, 0, REG_SZ, (BYTE*) DISPLAYNAME, sizeof(TCHAR) * (1 + _tcslen(DISPLAYNAME))))
{
OutputDebugString(TEXT("Failed to set the named value for the GUID key under CLSID"));
RegCloseKey(hkGUID);
return E_FAIL;
}
// Now create the standard OLE server key
if (ERROR_SUCCESS != RegCreateKeyEx(hkGUID, TEXT("InprocServer32"), 0, TEXT("REG_SZ"), 0, KEY_WRITE, NULL, &hkReg, &dwHow))
{
OutputDebugString(TEXT("Failed to create the InprocServer32 key"));
RegCloseKey(hkGUID);
return E_FAIL;
}
// Now set the named value under this key
if (ERROR_SUCCESS != RegSetValueEx(hkReg, NULL, 0, REG_SZ, (BYTE*) EXEPATH, sizeof(TCHAR) * (1 + _tcslen(EXEPATH))))
{
OutputDebugString(TEXT("Failed to set the named value for the LocalServer32 key"));
RegCloseKey(hkReg);
RegCloseKey(hkGUID);
return E_FAIL;
}
RegCloseKey(hkReg);
// This is the *only* thing which marks this as a sip
if (ERROR_SUCCESS != RegCreateKeyEx(hkGUID, TEXT("IsSIPInputMethod"), 0, TEXT("REG_SZ"), 0, KEY_WRITE, NULL, &hkReg, &dwHow))
{
OutputDebugString(TEXT("Failed to create the IsSIPInputMethod key"));
RegCloseKey(hkGUID);
return E_FAIL;
}
// Now set the named value under this key
if (ERROR_SUCCESS != RegSetValueEx(hkReg, NULL, 0, REG_SZ, (BYTE *) STRINGONE, sizeof(TCHAR) * (1 + _tcslen(STRINGONE))))
{
OutputDebugString(TEXT("Failed to set the named value for the IsSIPInputMethod key"));
RegCloseKey(hkReg);
RegCloseKey(hkGUID);
return E_FAIL;
}
RegCloseKey(hkReg);
// This controls the icon we see in the sip menu
if (ERROR_SUCCESS != RegCreateKeyEx(hkGUID, TEXT("DefaultIcon"), 0, TEXT("REG_SZ"), 0, KEY_WRITE, NULL, &hkReg, &dwHow))
{
OutputDebugString(TEXT("Failed to create the DefaultIcon key"));
RegCloseKey(hkGUID);
return E_FAIL;
}
if (ERROR_SUCCESS != RegSetValueEx(hkReg, NULL, 0, REG_SZ, (BYTE *) ICONNAME, sizeof(TCHAR) * (1 + _tcslen(ICONNAME))))
{
OutputDebugString(TEXT("Failed to set the named value for the DefaultIcon key"));
RegCloseKey(hkReg);
RegCloseKey(hkGUID);
return E_FAIL;
}
RegCloseKey(hkReg);
RegCloseKey(hkGUID);
OutputDebugString(TEXT("Succesfully registered PenInput."));
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -