• Skip to content
  • Skip to link menu
KDE 4.1 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 Jaroslaw Staniek <js@iidea.pl>
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 <QFile>
00025 #include <QWidget>
00026 
00027 #include <windows.h>
00028 
00029 // TODO move to a shared lib
00030 static int runDll(WId windowId, const QString& libraryName, const QString& functionName, 
00031             const QString& arguments = QString())
00032 {
00033   HMODULE libHandle = LoadLibraryA( QFile::encodeName(libraryName).constData() );
00034   if (!libHandle)
00035     return false;
00036   typedef int (WINAPI *FunctionType)(HWND, HMODULE, LPCSTR, int);
00037   FunctionType function 
00038     = (FunctionType)GetProcAddress( libHandle, functionName.toLatin1().constData() );
00039   if (!function)
00040     return false;
00041   int result = function((HWND)windowId, libHandle, (LPCSTR)arguments.toLatin1().constData(), SW_SHOW);
00042   FreeLibrary(libHandle);
00043   return result;
00044 }
00045 
00046 // TODO move to a shared lib
00047 static int runDll(QWidget* parent, const QString& libraryName, const QString& functionName, 
00048             const QString& arguments = QString())
00049 {
00050   return runDll(parent ? parent->winId() : 0, libraryName, functionName, arguments);
00051 }
00052 
00053 
00054 // Windows implementation using "OpenAs_RunDLL" entry
00055 bool KRun::KRunPrivate::displayNativeOpenWithDialog( const KUrl::List& lst, QWidget* window, bool tempFiles,
00056                                                const QString& suggestedFileName, const QByteArray& asn )
00057 {
00058     Q_UNUSED(tempFiles);
00059     Q_UNUSED(suggestedFileName);
00060     Q_UNUSED(asn);
00061 
00062     QStringList fnames;
00063     foreach( const KUrl& url, lst )
00064     {
00065       fnames += QFile::encodeName( 
00066         QDir::toNativeSeparators( url.path() ) ); // QFile::encodeName() needed because we will use toLatin1()
00067     }
00068     int result = runDll( window, QLatin1String("shell32.dll"), QLatin1String("OpenAs_RunDLL"), 
00069                          QFile::encodeName( fnames.join(" ") ) );
00070     return result == 0;
00071 }

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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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