• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

krun_win.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2008 Jarosław Staniek <staniek@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "krun.h"
00021 #include "krun_p.h"
00022 
00023 #include <QDir>
00024 #include <QWidget>
00025 
00026 #include <windows.h>
00027 
00028 // TODO move to a shared lib
00029 static int runDll(WId windowId, const QString& libraryName, const QByteArray& functionName, 
00030             const QString& arguments)
00031 {
00032   HMODULE libHandle = LoadLibraryW( (LPCWSTR)libraryName.utf16() );
00033   if (!libHandle)
00034     return 0;
00035   typedef int (WINAPI *FunctionType)(HWND, HMODULE, LPCWSTR, int);
00036   FunctionType function 
00037     = (FunctionType)GetProcAddress( libHandle, functionName.constData() );
00038   if (!function)
00039     return 0;
00040   int result = function((HWND)windowId, libHandle, (LPCWSTR)arguments.utf16(), SW_SHOW);
00041   FreeLibrary(libHandle);
00042   return result;
00043 }
00044 
00045 static int runDll(WId windowId, const QString& libraryName, const QByteArray& functionName, 
00046             const QByteArray& arguments)
00047 {
00048   HMODULE libHandle = LoadLibraryW( (LPCWSTR)libraryName.utf16() );
00049   if (!libHandle)
00050     return 0;
00051   typedef int (WINAPI *FunctionType)(HWND, HMODULE, LPCSTR, int);
00052   FunctionType function 
00053     = (FunctionType)GetProcAddress( libHandle, functionName.constData() );
00054   if (!function)
00055     return 0;
00056   int result = function((HWND)windowId, libHandle, (LPCSTR)arguments.constData(), SW_SHOW);
00057   FreeLibrary(libHandle);
00058   return result;
00059 }
00060 
00061 // TODO move to a shared lib
00062 static int runDll(QWidget* parent, const QString& libraryName, const QByteArray& functionName, 
00063             const QString& arguments)
00064 {
00065   return runDll(parent ? parent->winId() : 0, libraryName, functionName, arguments);
00066 }
00067 
00068 
00069 // Windows implementation using "OpenAs_RunDLL" entry
00070 bool KRun::KRunPrivate::displayNativeOpenWithDialog( const KUrl::List& lst, QWidget* window, bool tempFiles,
00071                                                const QString& suggestedFileName, const QByteArray& asn )
00072 {
00073     Q_UNUSED(tempFiles);
00074     Q_UNUSED(suggestedFileName);
00075     Q_UNUSED(asn);
00076 
00077     QStringList fnames;
00078     foreach( const KUrl& url, lst )
00079     {
00080       fnames += QDir::toNativeSeparators( url.path() );
00081     }
00082     int result = runDll( window,
00083                          QLatin1String("shell32.dll"),
00084                          "OpenAs_RunDLLW", 
00085                          fnames.join(QLatin1String(" ")) );
00086     return result == 0;
00087 }

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal