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 <QWidget>
00025
00026 #include <windows.h>
00027
00028
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
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
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 }