Index: base/applications/fontview/CMakeLists.txt =================================================================== --- base/applications/fontview/CMakeLists.txt (revision 59468) +++ base/applications/fontview/CMakeLists.txt (working copy) @@ -4,6 +4,6 @@ fontview.c fontview.rc) -set_module_type(fontview win32gui) -add_importlibs(fontview comdlg32 gdi32 shell32 user32 msvcrt kernel32) +set_module_type(fontview win32gui UNICODE) +add_importlibs(fontview comdlg32 gdi32 shell32 user32 msvcrt kernel32 advapi32) add_cd_file(TARGET fontview DESTINATION reactos/system32 FOR all) Index: base/applications/fontview/display.c =================================================================== --- base/applications/fontview/display.c (revision 59468) +++ base/applications/fontview/display.c (working copy) @@ -446,7 +446,7 @@ pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA); #endif docinfo.cbSize = sizeof(DOCINFO); - docinfo.lpszDocName = "Printing Font"; + docinfo.lpszDocName = L"Printing Font"; docinfo.lpszOutput = NULL; docinfo.lpszDatatype = NULL; docinfo.fwType = 0; Index: base/applications/fontview/fontview.c =================================================================== --- base/applications/fontview/fontview.c (revision 59468) +++ base/applications/fontview/fontview.c (working copy) @@ -79,11 +79,8 @@ LocalFree(hMemText); } -int WINAPI -WinMain (HINSTANCE hThisInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) +INT WINAPI + wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) { int argc; WCHAR** argv; @@ -105,7 +102,7 @@ break; } - g_hInstance = hThisInstance; + g_hInstance = hInstance; /* Get unicode command line */ argv = CommandLineToArgvW(GetCommandLineW(), &argc); @@ -178,7 +175,7 @@ return -1; } - if (!Display_InitClass(hThisInstance)) + if (!Display_InitClass(hInstance)) { ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS); return -1; @@ -190,7 +187,7 @@ wincl.lpfnWndProc = MainWndProc; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0; - wincl.hInstance = hThisInstance; + wincl.hInstance = hInstance; wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND; @@ -217,10 +214,10 @@ 375, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ - hThisInstance, /* Program Instance handler */ + hInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); - ShowWindow(hMainWnd, nCmdShow); + ShowWindow(hMainWnd, nShowCmd); /* Main message loop */ while (GetMessage (&msg, NULL, 0, 0)) @@ -336,19 +333,87 @@ MainWnd_OnInstall(HWND hwnd) { DWORD fontExists; + HKEY hKey; + LPWSTR subKey = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; + WCHAR szDestDir[256]; /* First, we have to find out if the font still exists. */ - fontExists = GetFileAttributes((LPCSTR)g_fileName); + fontExists = GetFileAttributesW(g_fileName); if (fontExists != 0xFFFFFFFF) /* If the file does not exist */ { ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, g_fileName); return -1; } + // Prepare the Registry Key + LONG res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, subKey, 0, KEY_ALL_ACCESS, &hKey); + + if(res != ERROR_SUCCESS) + { + MessageBoxW(hwnd, L"There is a corruption in the Registry.", L"Debug1", MB_OK); + RegCloseKey(hKey); + return -1; + } - //CopyFile(g_fileName, NULL, TRUE); +/* +Prepare the final directory string +*/ + + WCHAR filename[256]; + wcscpy(filename, g_fileName); + UINT i; + for(i=wcslen(filename);;i--) + { + if(filename[i]==L'\\') + { + i++; + break; + } + } + WCHAR fileExt[256]; + UINT j; + for(j=i;j<=wcslen(filename);j++) + { + wcscat(fileExt,(LPWSTR)&filename[j]); + }; + /* Or Maybe \\WINDOWS\\Fonts ?*/ + swprintf(szDestDir, L"%%windir%%\\Fonts\\%s", fileExt); + + // Check if already exists. + DWORD exists = GetFileAttributesW(szDestDir); + if (exists == 0xFFFFFFFF) + { + //To Register if the value is missing? + MessageBoxW(hwnd,L"This font is already installed!", L"Already Installed", MB_OK); + RegCloseKey(hKey); + return 0; + } + + /* Copy the file */ + if(!CopyFileW(filename, szDestDir, TRUE)) + { + MessageBoxW(hwnd,L"Error with copying the font file.", L"File Error", MB_OK); + RegCloseKey(hKey); + return -1; + } + + /* Register The Font */ + res = RegSetValueExW(hKey, g_ExtLogFontW.elfFullName, 0, REG_SZ, (LPBYTE)fileExt, wcslen(fileExt)+1); + if(res != ERROR_SUCCESS) + { + MessageBoxW(hwnd, L"There is a corruption in the Registry.", L"Debug2", MB_OK); + RegCloseKey(hKey); + return -1; + } + + /* if all of this goes correctly, message the user about success */ + + MessageBox(hwnd, L"Font Installation Completed.", L"Success", MB_OK); + + // And to get rid of the below! + //MessageBox(hwnd, TEXT("This function is unimplemented"), TEXT("Unimplemented"), MB_OK); + // Close the key + RegCloseKey(hKey); - MessageBox(hwnd, TEXT("This function is unimplemented"), TEXT("Unimplemented"), MB_OK); - return 0; } Index: base/applications/fontview/fontview.h =================================================================== --- base/applications/fontview/fontview.h (revision 59468) +++ base/applications/fontview/fontview.h (working copy) @@ -1,6 +1,7 @@ #include #include #include +#include #include #include