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

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kio
krun_win.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2008 JarosÅ‚aw Staniek <staniek@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "krun.h"
21 #include "krun_p.h"
22 
23 #include <QDir>
24 #include <QWidget>
25 
26 #include <windows.h>
27 
28 // TODO move to a shared lib
29 static int runDll(WId windowId, const QString& libraryName, const QByteArray& functionName,
30  const QString& arguments)
31 {
32  HMODULE libHandle = LoadLibraryW( (LPCWSTR)libraryName.utf16() );
33  if (!libHandle)
34  return 0;
35  typedef int (WINAPI *FunctionType)(HWND, HMODULE, LPCWSTR, int);
36 #ifdef _WIN32_WCE
37  QString functionNamestr = QString(functionName);
38  FunctionType function
39  = (FunctionType)GetProcAddressW( libHandle, functionNamestr.utf16() );
40 #else
41  FunctionType function
42  = (FunctionType)GetProcAddress( libHandle, functionName.constData() );
43 #endif
44  if (!function)
45  return 0;
46  int result = function((HWND)windowId, libHandle, (LPCWSTR)arguments.utf16(), SW_SHOW);
47  FreeLibrary(libHandle);
48  return result;
49 }
50 
51 static int runDll(WId windowId, const QString& libraryName, const QByteArray& functionName,
52  const QByteArray& arguments)
53 {
54  HMODULE libHandle = LoadLibraryW( (LPCWSTR)libraryName.utf16() );
55  if (!libHandle)
56  return 0;
57  typedef int (WINAPI *FunctionType)(HWND, HMODULE, LPCSTR, int);
58 #ifdef _WIN32_WCE
59  QString functionNamestr = QString(functionName);
60  FunctionType function
61  = (FunctionType)GetProcAddressW( libHandle, functionNamestr.utf16() );
62 #else
63  FunctionType function
64  = (FunctionType)GetProcAddress( libHandle, functionName.constData() );
65 #endif
66  if (!function)
67  return 0;
68  int result = function((HWND)windowId, libHandle, (LPCSTR)arguments.constData(), SW_SHOW);
69  FreeLibrary(libHandle);
70  return result;
71 }
72 
73 // TODO move to a shared lib
74 static int runDll(QWidget* parent, const QString& libraryName, const QByteArray& functionName,
75  const QString& arguments)
76 {
77  return runDll(parent ? parent->winId() : 0, libraryName, functionName, arguments);
78 }
79 
80 
81 // Windows implementation using "OpenAs_RunDLL" entry
82 bool KRun::KRunPrivate::displayNativeOpenWithDialog( const KUrl::List& lst, QWidget* window, bool tempFiles,
83  const QString& suggestedFileName, const QByteArray& asn )
84 {
85  Q_UNUSED(tempFiles);
86  Q_UNUSED(suggestedFileName);
87  Q_UNUSED(asn);
88 
89  QStringList fnames;
90  foreach( const KUrl& url, lst )
91  {
92  fnames += QDir::toNativeSeparators( url.path() );
93  }
94  int result = runDll( window,
95  QLatin1String("shell32.dll"),
96  "OpenAs_RunDLLW",
97  fnames.join(QLatin1String(" ")) );
98  return result == 0;
99 }
QWidget
QDir::toNativeSeparators
QString toNativeSeparators(const QString &pathName)
QByteArray
KRun::url
KUrl url() const
Returns the url.
Definition: krun.cpp:1620
QStringList::join
QString join(const QString &separator) const
KUrl
KRun::KRunPrivate::displayNativeOpenWithDialog
static bool displayNativeOpenWithDialog(const KUrl::List &lst, QWidget *window, bool tempFiles, const QString &suggestedFileName, const QByteArray &asn)
Definition: krun_win.cpp:82
QByteArray::constData
const char * constData() const
QWidget::winId
WId winId() const
QString
KUrl::path
QString path(AdjustPathOption trailing=LeaveTrailingSlash) const
QStringList
runDll
static int runDll(WId windowId, const QString &libraryName, const QByteArray &functionName, const QString &arguments)
Definition: krun_win.cpp:29
KUrl::List
krun.h
QString::utf16
const ushort * utf16() const
QLatin1String
krun_p.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal