00001 /* findpk.cpp: find a PK file -*- C++ -*- 00002 00003 Copyright (C) 2006-2007 Christian Schenk 00004 00005 This file is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published 00007 by the Free Software Foundation; either version 2, or (at your 00008 option) any later version. 00009 00010 This file is distributed in the hope that it will be useful, but 00011 WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this file; if not, write to the Free Software 00017 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00018 USA. */ 00019 00020 #include <cstdio> 00021 00022 #import <MiKTeX206-session.tlb> 00023 00024 using namespace MiKTeXSession2_6; 00025 00026 int 00027 main (/*[in]*/ int argc, 00028 /*[in]*/ const char ** argv) 00029 { 00030 if (argc != 4) 00031 { 00032 puts ("Usage: findpk FONTNAME MODE DPI"); 00033 puts (" e.g.: findpk cmr10 ljfour 600"); 00034 return (1); 00035 } 00036 00037 if (FAILED(CoInitialize(0))) 00038 { 00039 puts ("COM library could not be initialized."); 00040 return (1); 00041 } 00042 00043 int retCode = 0; 00044 00045 try 00046 { 00047 ISessionPtr pSession; 00048 HRESULT hr = pSession.CreateInstance(L"MiKTeX.Session"); 00049 if (FAILED(hr)) 00050 { 00051 _com_raise_error (hr); 00052 } 00053 _bstr_t fontName (argv[1]); 00054 _bstr_t mode (argv[2]); 00055 long dpi = atoi(argv[3]); 00056 _bstr_t path; 00057 if (pSession->FindPkFile(fontName, mode, dpi, path.GetAddress())) 00058 { 00059 puts (path); 00060 } 00061 } 00062 catch (const _com_error & e) 00063 { 00064 puts (e.Description()); 00065 retCode = 1; 00066 } 00067 00068 CoUninitialize (); 00069 00070 return (retCode); 00071 }