2
0
mirror of https://github.com/boostorg/process.git synced 2026-01-19 04:22:15 +00:00

completly removed windows.h header, now i'll start with testing

This commit is contained in:
klemens-morgenstern
2015-10-11 22:22:17 +02:00
parent ef24f3d16a
commit 56c3bf848a
11 changed files with 215 additions and 43 deletions

View File

@@ -0,0 +1,57 @@
/*
* GetSystemDirectory.hpp
*
* Created on: 11.10.2015
* Author: Klemens
*/
#ifndef BOOST_DETAIL_WINAPI_GETSYSTEMDIRECTORY_HPP_
#define BOOST_DETAIL_WINAPI_GETSYSTEMDIRECTORY_HPP_
#include <boost/detail/winapi/basic_types.hpp>
namespace boost
{
namespace detail
{
namespace winapi
{
extern "C" {
#if defined( BOOST_USE_WINDOWS_H )
using ::GetSystemDirectoryA;
using ::GetSystemDirectoryW;
#else
__declspec(dllimport) unsigned int WINAPI GetSystemDirectoryA (LPSTR_ lpBuffer, unsigned int uSize);
__declspec(dllimport) unsigned int WINAPI GetSystemDirectoryW (LPWSTR_ lpBuffer, unsigned int uSize);
#if defined(UNICODE) || defined(_UNICODE)
inline unsigned int GetSystemDirectory (LPWSTR_ lpBuffer, unsigned int uSize)
{
return GetSystemDirectoryW(lpBuffer, uSize);
}
#else
inline unsigned int GetSystemDirectory (LPSTR_ lpBuffer, unsigned int uSize)
{
return GetSystemDirectoryA(lpBuffer, uSize);
}
#endif
}
}
}
}
#endif /* BOOST_DETAIL_WINAPI_GETSYSTEMDIRECTORY_HPP_ */

View File

@@ -34,7 +34,7 @@ using ::CreateProcessW;
#else
__declspec(dllimport) __declspec (noreturn) void WINAPI ExitProcess (unsigned int uExitCode);
__declspec(dllimport) int WINAPI TerminateProcess (HANDLE_ hProcess, unsigned int uExitCode);
__declspec(dllimport) int WINAPI TerminateProcess (HANDLE_ hProcess, unsigned int uExitCode);
__declspec(dllimport) int WINAPI GetExitCodeProcess (HANDLE_ hProcess, DWORD_* lpExitCode);
__declspec(dllimport) int WINAPI CreateProcessA (LPCSTR_ lpApplicationName, LPSTR_ lpCommandLine, LPSECURITY_ATTRIBUTES_ lpProcessAttributes, LPSECURITY_ATTRIBUTES_ lpThreadAttributes, int bInheritHandles, DWORD_ dwCreationFlags, LPVOID_ lpEnvironment, LPCSTR_ lpCurrentDirectory, STARTUPINFOA_* lpStartupInfo, PROCESS_INFORMATION_* lpProcessInformation);
@@ -42,7 +42,6 @@ __declspec(dllimport) int WINAPI CreateProcessW (LPCWSTR_ lpApplicationName, LPW
}
#endif
#if defined(UNICODE) || defined(_UNICODE)
inline int CreateProcess (LPCWSTR_ lpApplicationName, LPWSTR_ lpCommandLine, LPSECURITY_ATTRIBUTES_ lpProcessAttributes, LPSECURITY_ATTRIBUTES_ lpThreadAttributes, int bInheritHandles, DWORD_ dwCreationFlags, LPVOID_ lpEnvironment, LPCWSTR_ lpCurrentDirectory, STARTUPINFOW_* lpStartupInfo, PROCESS_INFORMATION_* lpProcessInformation)
@@ -55,6 +54,7 @@ inline int CreateProcess (LPCSTR_ lpApplicationName, LPSTR_ lpCommandLine, LPSE
return CreateProcessA (lpApplicationName, lpCommandLine, lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags, lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
}
#endif
#endif
}

View File

@@ -81,7 +81,6 @@ struct STARTUPINFOW_ {
HANDLE_ hStdError;
} ;
#endif
#if defined(UNICODE) || defined(_UNICODE)
typedef STARTUPINFOW_ STARTUPINFO_;
@@ -102,6 +101,7 @@ struct STARTUPINFOEX_ {
PROC_THREAD_ATTRIBUTE_LIST_* lpAttributeList;
};
#endif
#endif
}
}}}

View File

@@ -0,0 +1,135 @@
/*
* shell_api.hpp
*
* Created on: 11.10.2015
* Author: Klemens
*/
#ifndef BOOST_DETAIL_WINAPI_SHELL_API_HPP_
#define BOOST_DETAIL_WINAPI_SHELL_API_HPP_
#include <boost/detail/winapi/basic_types.hpp>
#include <boost/detail/winapi/config.hpp>
namespace boost
{
namespace detail
{
namespace winapi
{
extern "C" {
#if defined( BOOST_USE_WINDOWS_H )
const DWORD_ shgfi_icon = SHGFI_ICON ;
const DWORD_ shgfi_displayname = SHGFI_DISPLAYNAME ;
const DWORD_ shgfi_typename = SHGFI_TYPENAME ;
const DWORD_ shgfi_attributes = SHGFI_ATTRIBUTES ;
const DWORD_ shgfi_iconlocation = SHGFI_ICONLOCATION ;
const DWORD_ shgfi_exetype = SHGFI_EXETYPE ;
const DWORD_ shgfi_sysiconindex = SHGFI_SYSICONINDEX ;
const DWORD_ shgfi_linkoverlay = SHGFI_LINKOVERLAY ;
const DWORD_ shgfi_selected = SHGFI_SELECTED ;
const DWORD_ shgfi_attr_specified = SHGFI_ATTR_SPECIFIED ;
const DWORD_ shgfi_largeicon = SHGFI_LARGEICON ;
const DWORD_ shgfi_smallicon = SHGFI_SMALLICON ;
const DWORD_ shgfi_openicon = SHGFI_OPENICON ;
const DWORD_ shgfi_shelliconsize = SHGFI_SHELLICONSIZE ;
const DWORD_ shgfi_pidl = SHGFI_PIDL ;
const DWORD_ shgfi_usefileattributes = SHGFI_USEFILEATTRIBUTES;
const DWORD_ shgfi_addoverlays = SHGFI_ADDOVERLAYS ;
const DWORD_ shgfi_overlayindex = SHGFI_OVERLAYINDEX ;
const DWORD_ max_path = MAX_PATH;
using ::SHGetFileInfoA;
using ::SHGetFileInfoW;
typedef ::SHFILEINFOA SHFILEINFOA_;
typedef ::SHFILEINFOW SHFILEINFOW_;
#else
struct ICON_ {};
typedef ICON_ *HICON_;
const DWORD_ max_path = 260;
struct SHFILEINFOA_ {
HICON_ hIcon;
int iIcon;
DWORD_ dwAttributes;
CHAR_ szDisplayName[260];
CHAR_ szTypeName[80];
} ;
struct SHFILEINFOW_ {
HICON_ hIcon;
int iIcon;
DWORD_ dwAttributes;
WCHAR_ szDisplayName[260];
WCHAR_ szTypeName[80];
};
const DWORD_ shgfi_icon = 0x000000100;
const DWORD_ shgfi_displayname = 0x000000200;
const DWORD_ shgfi_typename = 0x000000400;
const DWORD_ shgfi_attributes = 0x000000800;
const DWORD_ shgfi_iconlocation = 0x000001000;
const DWORD_ shgfi_exetype = 0x000002000;
const DWORD_ shgfi_sysiconindex = 0x000004000;
const DWORD_ shgfi_linkoverlay = 0x000008000;
const DWORD_ shgfi_selected = 0x000010000;
const DWORD_ shgfi_attr_specified = 0x000020000;
const DWORD_ shgfi_largeicon = 0x000000000;
const DWORD_ shgfi_smallicon = 0x000000001;
const DWORD_ shgfi_openicon = 0x000000002;
const DWORD_ shgfi_shelliconsize = 0x000000004;
const DWORD_ shgfi_pidl = 0x000000008;
const DWORD_ shgfi_usefileattributes = 0x000000010;
const DWORD_ shgfi_addoverlays = 0x000000020;
const DWORD_ shgfi_overlayindex = 0x000000040;
__declspec(dllimport) DWORD_* WINAPI SHGetFileInfoA (LPCSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOA_ *psfinsigned, unsigned int cbFileInfons, unsigned int uFlags);
__declspec(dllimport) DWORD_* WINAPI SHGetFileInfoW (LPCWSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOW_ *psfinsigned, unsigned int cbFileInfons, unsigned int uFlags);
}
#endif
#if defined(UNICODE) || definde(_UNICODE)
typedef SHFILEINFOW_ SHFILEINFO_;
inline DWORD_* SHGetFileInfo (LPCWSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOW_ *psfinsigned, unsigned int cbFileInfons, unsigned int uFlags)
{
return SHGetFileInfoW(pszPath, dwFileAttributes, psfinsigned, cbFileInfons, uFlags);
}
#else
typedef SHFILEINFOA_ SHFILEINFO_;
inline DWORD_* SHGetFileInfo (LPCSTR_ pszPath, DWORD_ dwFileAttributes, SHFILEINFOA_ *psfinsigned, unsigned int cbFileInfons, unsigned int uFlags)
{
return SHGetFileInfoA (pszPath, dwFileAttributes, psfinsigned, cbFileInfons, uFlags);
}
#endif
}
}
}
#endif /* BOOST_DETAIL_WINAPI_SHELL_API_HPP_ */

View File

@@ -89,28 +89,4 @@ const DWORD_ sw_otherunzoom = 4 ;
}
}
//STARTF_USESTDHANDLES
#ifndef NOSHOWWINDOW
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
#endif /* BOOST_DETAIL_WINAPI_SHOW_WINDOWS_HPP_ */

View File

@@ -26,8 +26,8 @@
# define BOOST_PROCESS_LAST_ERROR errno
# define BOOST_PROCESS_PLATFORM posix
#elif defined(BOOST_WINDOWS_API)
# include <Windows.h>
# define BOOST_PROCESS_LAST_ERROR GetLastError()
# include <boost/detail/winapi/GetLastError.hpp>
# define BOOST_PROCESS_LAST_ERROR ::boost::detail::winapi::GetLastError()
# define BOOST_PROCESS_PLATFORM windows
#endif

View File

@@ -13,7 +13,6 @@
#include <boost/process/config.hpp>
#include <boost/process/windows/pipe.hpp>
#include <boost/system/error_code.hpp>
#include <Windows.h>
namespace boost { namespace process { namespace windows {

View File

@@ -19,10 +19,11 @@ struct pipe
boost::detail::winapi::HANDLE_ source;
boost::detail::winapi::HANDLE_ sink;
pipe(HANDLE source, HANDLE sink) : source(source), sink(sink) {}
pipe(boost::detail::winapi::HANDLE_ source, boost::detail::winapi::HANDLE_ sink) : source(source), sink(sink) {}
};
inline pipe make_pipe(HANDLE source, HANDLE sink)
inline pipe make_pipe(boost::detail::winapi::HANDLE_ source,
boost::detail::winapi::HANDLE_ sink)
{
return pipe(source, sink);
}

View File

@@ -18,7 +18,9 @@
#include <string>
#include <stdexcept>
#include <stdlib.h>
#include <Shellapi.h>
#include <boost/detail/winapi/shell_api.hpp>
namespace boost { namespace process { namespace windows {
@@ -52,7 +54,7 @@ inline std::wstring search_path(const std::wstring &filename,
boost::system::error_code ec;
bool file = boost::filesystem::is_regular_file(p2, ec);
if (!ec && file &&
SHGetFileInfoW(p2.c_str(), 0, 0, 0, SHGFI_EXETYPE))
::boost::detail::winapi::SHGetFileInfoW(p2.c_str(), 0, 0, 0, ::boost::detail::winapi::shgfi_exetype))
{
return p2.wstring();
}
@@ -89,7 +91,7 @@ inline std::string search_path(const std::string &filename,
boost::system::error_code ec;
bool file = boost::filesystem::is_regular_file(p2, ec);
if (!ec && file &&
SHGetFileInfoA(p2.string().c_str(), 0, 0, 0, SHGFI_EXETYPE))
::boost::detail::winapi::SHGetFileInfoA(p2.string().c_str(), 0, 0, 0, ::boost::detail::winapi::shgfi_exetype))
{
return p2.string();
}

View File

@@ -13,14 +13,16 @@
#include <boost/process/config.hpp>
#include <boost/system/error_code.hpp>
#include <boost/filesystem/path.hpp>
#include <Windows.h>
#include <boost/detail/winapi/basic_types.hpp>
#include <boost/detail/winapi/GetSystemDirectory.hpp>
namespace boost { namespace process { namespace windows {
inline boost::filesystem::path shell_path()
{
TCHAR sysdir[MAX_PATH];
UINT size = ::GetSystemDirectory(sysdir, sizeof(sysdir));
//260 is MAX_PATH but should be sufficient anyway.
char sysdir[260];
unsigned int size = ::boost::detail::winapi::GetSystemDirectory(sysdir, sizeof(sysdir));
if (!size)
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("GetSystemDirectory() failed");
boost::filesystem::path p = sysdir;
@@ -29,8 +31,8 @@ inline boost::filesystem::path shell_path()
inline boost::filesystem::path shell_path(boost::system::error_code &ec)
{
TCHAR sysdir[MAX_PATH];
UINT size = ::GetSystemDirectory(sysdir, sizeof(sysdir));
char sysdir[260];
unsigned int size = ::boost::detail::winapi::GetSystemDirectory(sysdir, sizeof(sysdir));
boost::filesystem::path p;
if (!size)
{

View File

@@ -13,21 +13,21 @@
#include <boost/process/config.hpp>
#include <boost/system/error_code.hpp>
#include <cstdlib>
#include <Windows.h>
#include <boost/detail/winapi/process_api.hpp>
namespace boost { namespace process { namespace windows {
template <class Process>
void terminate(const Process &p)
{
if (!::TerminateProcess(p.process_handle(), EXIT_FAILURE))
if (!::boost::detail::winapi::TerminateProcess(p.process_handle(), EXIT_FAILURE))
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("TerminateProcess() failed");
}
template <class Process>
void terminate(const Process &p, boost::system::error_code &ec)
{
if (!::TerminateProcess(p.process_handle(), EXIT_FAILURE))
if (!::boost::detail::winapi::TerminateProcess(p.process_handle(), EXIT_FAILURE))
BOOST_PROCESS_RETURN_LAST_SYSTEM_ERROR(ec);
else
ec.clear();