KIO
krun_win.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
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
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
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() ) );
00067 }
00068 int result = runDll( window, QLatin1String("shell32.dll"), QLatin1String("OpenAs_RunDLL"),
00069 QFile::encodeName( fnames.join(" ") ) );
00070 return result == 0;
00071 }