2763 lines
93 KiB
C++
2763 lines
93 KiB
C++
#pragma once
|
||
#include "windows.h"
|
||
#include <stdlib.h>
|
||
#include <stdio.h>
|
||
#include <iostream>
|
||
#include <thread>
|
||
#include <Shlobj.h>
|
||
#include <commdlg.h>
|
||
#include <functional>
|
||
#include <future>
|
||
#include "TimeSpan.h"
|
||
#include "NativeFunc.h"
|
||
#include "List.h"
|
||
#pragma comment(lib,"Gdi32.lib")
|
||
//only Ansi for text encoding in this lib
|
||
|
||
|
||
|
||
#define var auto
|
||
using namespace std;
|
||
extern "C" void* CoreRT_StaticInitialization();
|
||
|
||
|
||
namespace System
|
||
{
|
||
class Random
|
||
{
|
||
private:
|
||
IntPtr _p;
|
||
public:
|
||
~Random()
|
||
{
|
||
System_IntPtr_Free(this->_p);
|
||
}
|
||
Random()
|
||
{
|
||
this->_p = System_Random_New();
|
||
}
|
||
Random(int seed)
|
||
{
|
||
this->_p = System_Random_NewI(seed);
|
||
}
|
||
int Next()
|
||
{
|
||
return System_Random_NextI(this->_p);
|
||
}
|
||
int Next(int max)
|
||
{
|
||
return System_Random_NextII(this->_p , max);
|
||
}
|
||
int Next(int min , int max)
|
||
{
|
||
return System_Random_NextIII(this->_p , min , max);
|
||
}
|
||
double NextDouble()
|
||
{
|
||
return System_Random_NextDouble(this->_p);
|
||
}
|
||
BYTE* NextBytes(int len)
|
||
{
|
||
return System_Random_NextBytes(this->_p , len);
|
||
}
|
||
};
|
||
class Console
|
||
{
|
||
public:
|
||
static char* ReadLine()
|
||
{
|
||
return System_Console_ReadLine();
|
||
}
|
||
static void WriteLine(const char* s = "")
|
||
{
|
||
System_Console_WriteLine(s);
|
||
}
|
||
static char ReadKey()
|
||
{
|
||
return System_Console_ReadKey();
|
||
}
|
||
static void Write(const char* s)
|
||
{
|
||
System_Console_Write(s);
|
||
}
|
||
};
|
||
class Environment
|
||
{
|
||
public:
|
||
static char* CurrentDirectory()
|
||
{
|
||
return System_Environment_CurrentDirectory();
|
||
}
|
||
static void _SetCurrentDirectory(const char* path)
|
||
{
|
||
System_Environment_SetCurrentDirectory(path);
|
||
}
|
||
};
|
||
class Math
|
||
{
|
||
public:
|
||
static double Round(double v , int dig)
|
||
{
|
||
return System_Math_Round(v , dig);
|
||
}
|
||
};
|
||
class Convert
|
||
{
|
||
public:
|
||
static INT16 ToInt16(const char* v)
|
||
{
|
||
return System_Convert_StringToInt16(v);
|
||
}
|
||
static INT32 ToInt32(const char* v)
|
||
{
|
||
return System_Convert_StringToInt32(v);
|
||
}
|
||
static INT64 ToInt64(const char* v)
|
||
{
|
||
return System_Convert_StringToInt64(v);
|
||
}
|
||
static UINT16 ToUInt16(const char* v)
|
||
{
|
||
return System_Convert_StringToUInt16(v);
|
||
}
|
||
static UINT32 ToUInt32(const char* v)
|
||
{
|
||
return System_Convert_StringToUInt32(v);
|
||
}
|
||
static UINT64 ToUInt64(const char* v)
|
||
{
|
||
return System_Convert_StringToUInt64(v);
|
||
}
|
||
static float ToFloat(const char* v)
|
||
{
|
||
return System_Convert_StringToFloat(v);
|
||
}
|
||
static double ToDouble(const char* v)
|
||
{
|
||
return System_Convert_StringToDouble(v);
|
||
}
|
||
static char* ToString(INT8 v)
|
||
{
|
||
return System_Convert_Int8ToString(v);
|
||
}
|
||
static char* ToString(INT16 v)
|
||
{
|
||
return System_Convert_Int16ToString(v);
|
||
}
|
||
static char* ToString(INT32 v)
|
||
{
|
||
return System_Convert_Int32ToString(v);
|
||
}
|
||
static char* ToString(INT64 v)
|
||
{
|
||
return System_Convert_Int64ToString(v);
|
||
}
|
||
static char* ToString(UINT16 v)
|
||
{
|
||
return System_Convert_UInt16ToString(v);
|
||
}
|
||
static char* ToString(UINT32 v)
|
||
{
|
||
return System_Convert_UInt32ToString(v);
|
||
}
|
||
static char* ToString(UINT64 v)
|
||
{
|
||
return System_Convert_UInt64ToString(v);
|
||
}
|
||
static char* ToString(float v)
|
||
{
|
||
return System_Convert_FloatToString(v);
|
||
}
|
||
static char* ToString(double v)
|
||
{
|
||
return System_Convert_DoubleToString(v);
|
||
}
|
||
static char* ToBase64String(BYTE* v , int len)
|
||
{
|
||
return System_Convert_ToBase64String(v , len);
|
||
}
|
||
static BYTE* FromBase64String(char* v , int* lentmp)
|
||
{
|
||
return System_Convert_FromBase64String(v , lentmp);
|
||
}
|
||
};
|
||
class DateTime
|
||
{
|
||
public:
|
||
IntPtr _t;
|
||
DateTime()
|
||
{}
|
||
DateTime(int year , int mounth , int day , int hour , int minute , int second , int millisecond)
|
||
{
|
||
this->_t = System_DateTime_New(year , mounth , day , hour , minute , second , millisecond);
|
||
}
|
||
char* ToString()
|
||
{
|
||
return System_DateTime_ToString(this->_t);
|
||
}
|
||
static DateTime* Parse(const char* time)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_Parse(time);
|
||
return result;
|
||
}
|
||
static DateTime* Now()
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_Now();
|
||
return result;
|
||
}
|
||
DateTime* Add(TimeSpan span)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_Add(this->_t , span);
|
||
return result;
|
||
}
|
||
DateTime* AddDays(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddDays(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddSeconds(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddSeconds(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddMinutes(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddMinutes(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddHours(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddHours(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddMilliseconds(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddMilliseconds(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddYears(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddYears(this->_t , v);
|
||
return result;
|
||
}
|
||
DateTime* AddTicks(int v)
|
||
{
|
||
DateTime* result = new DateTime();
|
||
result->_t = System_DateTime_AddTicks(this->_t , v);
|
||
return result;
|
||
}
|
||
int Year()
|
||
{
|
||
return System_DateTime_Year(this->_t);
|
||
}
|
||
int Month()
|
||
{
|
||
return System_DateTime_Month(this->_t);
|
||
}
|
||
int Day()
|
||
{
|
||
return System_DateTime_Day(this->_t);
|
||
}
|
||
int Hour()
|
||
{
|
||
return System_DateTime_Hour(this->_t);
|
||
}
|
||
int Minute()
|
||
{
|
||
return System_DateTime_Minute(this->_t);
|
||
}
|
||
int Second()
|
||
{
|
||
return System_DateTime_Second(this->_t);
|
||
}
|
||
int Millisecond()
|
||
{
|
||
return System_DateTime_Millisecond(this->_t);
|
||
}
|
||
INT64 Ticks()
|
||
{
|
||
return System_DateTime_Ticks(this->_t);
|
||
}
|
||
};
|
||
namespace Text
|
||
{
|
||
class StringBuilder
|
||
{
|
||
IntPtr _b;
|
||
public:
|
||
StringBuilder()
|
||
{
|
||
this->_b = System_Text_StringBuilder_New();
|
||
}
|
||
StringBuilder(const char* s)
|
||
{
|
||
this->_b = System_Text_StringBuilder_NewI(s);
|
||
}
|
||
~StringBuilder()
|
||
{
|
||
free(this->_b);
|
||
}
|
||
void Append(const char* s)
|
||
{
|
||
System_Text_StringBuilder_Append(this->_b , s);
|
||
}
|
||
void AppendLine(const char* s)
|
||
{
|
||
System_Text_StringBuilder_AppendLine(this->_b , s);
|
||
}
|
||
void Insert(int index , const char* s)
|
||
{
|
||
System_Text_StringBuilder_Insert(this->_b , index , s);
|
||
}
|
||
int GetLength()
|
||
{
|
||
return System_Text_StringBuilder_GetLength(this->_b);
|
||
}
|
||
void SetLength(int len)
|
||
{
|
||
return System_Text_StringBuilder_SetLength(this->_b , len);
|
||
}
|
||
void Clear()
|
||
{
|
||
System_Text_StringBuilder_Clear(this->_b);
|
||
}
|
||
char* ToString()
|
||
{
|
||
return System_Text_StringBuilder_ToString(this->_b);
|
||
}
|
||
};
|
||
class Encoding
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
static Encoding* Default()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_Default();
|
||
return result;
|
||
}
|
||
static Encoding* UTF7()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_UTF7();
|
||
return result;
|
||
}
|
||
static Encoding* UTF8()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_UTF8();
|
||
return result;
|
||
}
|
||
static Encoding* UTF32()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_UTF32();
|
||
return result;
|
||
}
|
||
static Encoding* Latin1()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_Latin1();
|
||
return result;
|
||
}
|
||
static Encoding* Unicode()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_Unicode();
|
||
return result;
|
||
}
|
||
static Encoding* ASCII()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_ASCII();
|
||
return result;
|
||
}
|
||
static Encoding* BigEndianUnicode()
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_BigEndianUnicode();
|
||
return result;
|
||
}
|
||
static Encoding* GetEncoding(const char* name)
|
||
{
|
||
Encoding* result = new Encoding();
|
||
result->_p = System_Text_Encoding_GetEncoding(name);
|
||
return result;
|
||
}
|
||
BYTE* GetBytes(const char* str , int* outlen)
|
||
{
|
||
return System_Text_Encoding_GetBytes(this->_p , str , outlen);
|
||
}
|
||
char* GetString(BYTE* bytes , int len)
|
||
{
|
||
return System_Text_Encoding_GetString(this->_p , bytes , len);
|
||
}
|
||
};
|
||
namespace RegularExpressions
|
||
{
|
||
class Regex
|
||
{
|
||
private:
|
||
const char* pattem;
|
||
public:
|
||
Regex(const char* _pattem)
|
||
{
|
||
this->pattem = _pattem;
|
||
}
|
||
vector<const char*> Matches(const char* text)
|
||
{
|
||
const char** tmp = 0;
|
||
int count = 0;
|
||
System_Text_RegularExpressions_Regex_Matches(text , this->pattem , &tmp , &count);
|
||
vector<const char*> result = vector<const char*>();
|
||
for(int i = 0; i < count; i++)
|
||
{
|
||
result.push_back(tmp[i]);
|
||
}
|
||
return result;
|
||
}
|
||
static vector<const char*> Matches(const char* text , const char* pat)
|
||
{
|
||
const char** tmp = 0;
|
||
int count = 0;
|
||
System_Text_RegularExpressions_Regex_Matches(text , pat , &tmp , &count);
|
||
vector<const char*> result = vector<const char*>();
|
||
for(int i = 0; i < count; i++)
|
||
{
|
||
result.push_back(tmp[i]);
|
||
}
|
||
return result;
|
||
}
|
||
vector<const char*> Split(const char* text)
|
||
{
|
||
const char** tmp = 0;
|
||
int count = 0;
|
||
System_Text_RegularExpressions_Regex_Slpite(text , this->pattem , &tmp , &count);
|
||
vector<const char*> result = vector<const char*>();
|
||
for(int i = 0; i < count; i++)
|
||
{
|
||
result.push_back(tmp[i]);
|
||
}
|
||
return result;
|
||
}
|
||
static vector<const char*> Split(const char* text , const char* pat)
|
||
{
|
||
const char** tmp = 0;
|
||
int count = 0;
|
||
System_Text_RegularExpressions_Regex_Slpite(text , pat , &tmp , &count);
|
||
vector<const char*> result = vector<const char*>();
|
||
for(int i = 0; i < count; i++)
|
||
{
|
||
result.push_back(tmp[i]);
|
||
}
|
||
return result;
|
||
}
|
||
char* Replace(const char* text , const char* replacement)
|
||
{
|
||
return System_Text_RegularExpressions_Regex_Replace(text , this->pattem , replacement);
|
||
}
|
||
static char* Replace(const char* text , const char* pat , const char* replacement)
|
||
{
|
||
return System_Text_RegularExpressions_Regex_Replace(text , pat , replacement);
|
||
}
|
||
};
|
||
}
|
||
}
|
||
namespace IO
|
||
{
|
||
using namespace System::Text;
|
||
class MemoryStream
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
MemoryStream()
|
||
{
|
||
this->_p = System_IO_MemoryStream_New();
|
||
}
|
||
~MemoryStream()
|
||
{
|
||
System_IntPtr_Free(this->_p);
|
||
}
|
||
MemoryStream(BYTE* v , INT32 len)
|
||
{
|
||
this->_p = System_IO_MemoryStream_NewI(v , len);
|
||
}
|
||
void Seek(long offset , SeekOrigin loc)
|
||
{
|
||
System_IO_MemoryStream_Seek(this->_p , offset , loc);
|
||
}
|
||
INT64 GetPosition()
|
||
{
|
||
return System_IO_MemoryStream_GetPosition(this->_p);
|
||
}
|
||
void GetPosition(INT64 len)
|
||
{
|
||
System_IO_MemoryStream_SetPosition(this->_p , len);
|
||
}
|
||
INT64 GetLength()
|
||
{
|
||
return System_IO_MemoryStream_GetLength(this->_p);
|
||
}
|
||
void SetLength(INT64 len)
|
||
{
|
||
System_IO_MemoryStream_SetLength(this->_p , len);
|
||
}
|
||
void Write(BYTE* buffer , INT32 len)
|
||
{
|
||
System_IO_MemoryStream_Write(this->_p , buffer , len);
|
||
}
|
||
void WriteByte(BYTE _byte)
|
||
{
|
||
System_IO_MemoryStream_WriteByte(this->_p , _byte);
|
||
}
|
||
int Read(BYTE* buffer , int offset , int len)
|
||
{
|
||
return System_IO_MemoryStream_Read(this->_p , buffer , offset , len);
|
||
}
|
||
int ReadByte()
|
||
{
|
||
return System_IO_MemoryStream_ReadByte(this->_p);
|
||
}
|
||
BYTE* ToArray()
|
||
{
|
||
return System_IO_MemoryStream_ToArray(this->_p);
|
||
}
|
||
};
|
||
class Stream
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
const IntPtr Null = System_IO_Stream_Null();
|
||
Stream& operator =(MemoryStream& ms)
|
||
{
|
||
this->_p = System_IO_Stream_FROMMEMORYSTREAM(ms._p);
|
||
return *this;
|
||
}
|
||
bool CanRead()
|
||
{
|
||
return System_IO_Stream_CanRead(this->_p);
|
||
}
|
||
bool CanSeek()
|
||
{
|
||
return System_IO_Stream_CanSeek(this->_p);
|
||
}
|
||
bool CanTimeout()
|
||
{
|
||
return System_IO_Stream_CanTimeout(this->_p);
|
||
}
|
||
bool CanWrite()
|
||
{
|
||
return System_IO_Stream_CanWrite(this->_p);
|
||
}
|
||
long Length()
|
||
{
|
||
return System_IO_Stream_Length(this->_p);
|
||
}
|
||
long GetPosition()
|
||
{
|
||
return System_IO_Stream_GetPosition(this->_p);
|
||
}
|
||
void SetPosition(long position)
|
||
{
|
||
return System_IO_Stream_SetPosition(this->_p , position);
|
||
}
|
||
int GetReadTimeout()
|
||
{
|
||
return System_IO_Stream_GetReadTimeout(this->_p);
|
||
}
|
||
void SetReadTimeout(int ReadTimeout)
|
||
{
|
||
return System_IO_Stream_SetReadTimeout(this->_p , ReadTimeout);
|
||
}
|
||
int GetWriteTimeout()
|
||
{
|
||
return System_IO_Stream_GetWriteTimeout(this->_p);
|
||
}
|
||
void SetWriteTimeout(int WriteTimeout)
|
||
{
|
||
return System_IO_Stream_SetWriteTimeout(this->_p , WriteTimeout);
|
||
}
|
||
void Write(byte* data , int len)
|
||
{
|
||
System_IO_Stream_Write(this->_p , data , len);
|
||
}
|
||
void WriteByte(byte data)
|
||
{
|
||
System_IO_Stream_WriteByte(this->_p , data);
|
||
}
|
||
int ReadByte()
|
||
{
|
||
return System_IO_Stream_ReadByte(this->_p);
|
||
}
|
||
int Read(IntPtr buffer , int offset , int len)
|
||
{
|
||
return System_IO_Stream_Read(this->_p , buffer , offset , len);
|
||
}
|
||
|
||
};
|
||
class StreamReader
|
||
{
|
||
public:
|
||
IntPtr _p; StreamReader(int)
|
||
{}
|
||
StreamReader(System::IO::Stream& stream)
|
||
{
|
||
this->_p = System_IO_StreamReader_New(stream._p);
|
||
}
|
||
StreamReader(System::IO::Stream& stream , bool detectEncodingFromByteOrderMarks)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewI(stream._p , detectEncodingFromByteOrderMarks);
|
||
}
|
||
StreamReader(System::IO::Stream& stream , System::Text::Encoding* encoding)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewII(stream._p , encoding->_p);
|
||
}
|
||
StreamReader(System::IO::Stream& stream , System::Text::Encoding* encoding , bool detect)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewIII(stream._p , encoding->_p , detect);
|
||
}
|
||
StreamReader(System::IO::Stream& stream , System::Text::Encoding* encoding , bool detect , int buffersize)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewIV(stream._p , encoding->_p , detect , buffersize);
|
||
}
|
||
StreamReader(System::IO::Stream& stream , System::Text::Encoding* encoding , bool detect , int buffersize , bool leaveOpen)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewV(stream._p , encoding->_p , detect , buffersize , leaveOpen);
|
||
}
|
||
StreamReader(const char* path)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewVI(path);
|
||
}
|
||
StreamReader(const char* path , bool detect)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewVII(path , detect);
|
||
}
|
||
StreamReader(const char* path , System::Text::Encoding* encoding)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewVIII(path , encoding->_p);
|
||
}
|
||
StreamReader(const char* path , System::Text::Encoding* encoding , bool detect)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewX(path , encoding->_p , detect);
|
||
}
|
||
StreamReader(const char* path , System::Text::Encoding* encoding , bool detect , int buffersize)
|
||
{
|
||
this->_p = System_IO_StreamReader_NewXI(path , encoding->_p , detect , buffersize);
|
||
}
|
||
void Close()
|
||
{
|
||
return System_IO_StreamReader_Close(this->_p);
|
||
}
|
||
void Peek()
|
||
{
|
||
return System_IO_StreamReader_Peek(this->_p);
|
||
}
|
||
void DiscardBufferedData()
|
||
{
|
||
return System_IO_StreamReader_DiscardBufferedData(this->_p);
|
||
}
|
||
int Read(IntPtr stream , char* buffer , int index , int count)
|
||
{
|
||
return System_IO_StreamReader_Read(this->_p , buffer , index , count);
|
||
}
|
||
char* ReadLine()
|
||
{
|
||
return System_IO_StreamReader_ReadLine(this->_p);
|
||
}
|
||
char* ReadToEnd()
|
||
{
|
||
return System_IO_StreamReader_ReadToEnd(this->_p);
|
||
}
|
||
};
|
||
class StreamWriter
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
StreamWriter(int)
|
||
{}
|
||
StreamWriter(System::IO::Stream& stream)
|
||
{
|
||
this->_p = System_IO_StreamWriter_New(stream._p);
|
||
}
|
||
StreamWriter(System::IO::Stream& stream , System::Text::Encoding* encoding)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewI(stream._p , encoding->_p);
|
||
}
|
||
StreamWriter(System::IO::Stream& stream , System::Text::Encoding* encoding , int buffersize)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewII(stream._p , encoding->_p , buffersize);
|
||
}
|
||
StreamWriter(System::IO::Stream& stream , System::Text::Encoding* encoding , int buffersize , bool leaveOpen)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewIII(stream._p , encoding->_p , buffersize , leaveOpen);
|
||
}
|
||
StreamWriter(const char* path)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewIV(path);
|
||
}
|
||
StreamWriter(const char* path , bool append)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewV(path , append);
|
||
}
|
||
StreamWriter(const char* path , bool append , System::Text::Encoding* encoding)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewVI(path , append , encoding->_p);
|
||
}
|
||
StreamWriter(const char* path , bool append , System::Text::Encoding* encoding , int buffersize)
|
||
{
|
||
this->_p = System_IO_StreamWriter_NewVII(path , append , encoding->_p , buffersize);
|
||
}
|
||
void Close()
|
||
{
|
||
return System_IO_StreamWriter_Close(this->_p);
|
||
}
|
||
void Flush()
|
||
{
|
||
return System_IO_StreamWriter_Flush(this->_p);
|
||
}
|
||
bool GetAutoFlush()
|
||
{
|
||
return System_IO_StreamWriter_GetAutoFlush(this->_p);
|
||
}
|
||
void SetAutoFlush(bool AutoFlush)
|
||
{
|
||
System_IO_StreamWriter_SetAutoFlush(this->_p , AutoFlush);
|
||
}
|
||
void WriteChar(char c)
|
||
{
|
||
return System_IO_StreamWriter_WriteChar(this->_p , c);
|
||
}
|
||
void Write(const char* s)
|
||
{
|
||
return System_IO_StreamWriter_Write(this->_p , s);
|
||
}
|
||
void WriteLine(const char* s)
|
||
{
|
||
return System_IO_StreamWriter_WriteLine(this->_p , s);
|
||
}
|
||
};
|
||
class FileStream
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
FileStream(const char* path , FileMode fmode , FileAccess acc)
|
||
{
|
||
this->_p = System_IO_FileStream_New(path , fmode , acc);
|
||
}
|
||
FileStream(IntPtr fhandle , FileAccess acc)
|
||
{
|
||
this->_p = System_IO_FileStream_NewI(fhandle , acc);
|
||
}
|
||
long GetPosition()
|
||
{
|
||
return System_IO_FileStream_GetPosition(this->_p);
|
||
}
|
||
void SetPosition(long pos)
|
||
{
|
||
System_IO_FileStream_SetPosition(this->_p , pos);
|
||
}
|
||
long GetLength()
|
||
{
|
||
return System_IO_FileStream_GetLength(this->_p);
|
||
}
|
||
void SetLength(long len)
|
||
{
|
||
System_IO_FileStream_SetLength(this->_p , len);
|
||
}
|
||
void Write(BYTE* _buffer , int len)
|
||
{
|
||
System_IO_FileStream_Write(this->_p , _buffer , len);
|
||
}
|
||
void WriteByte(BYTE b)
|
||
{
|
||
System_IO_FileStream_WriteByte(this->_p , b);
|
||
}
|
||
int Read(BYTE* buffer , int offset , int len)
|
||
{
|
||
return System_IO_FileStream_Read(this->_p , buffer , offset , len);
|
||
}
|
||
int ReadByte()
|
||
{
|
||
return System_IO_FileStream_ReadByte(this->_p);
|
||
}
|
||
void Seek(long offset , SeekOrigin loc)
|
||
{
|
||
System_IO_FileStream_Seek(this->_p , offset , loc);
|
||
}
|
||
void Flush()
|
||
{
|
||
System_IO_FileStream_Flush(this->_p);
|
||
}
|
||
void FlushI(bool flushToDisk)
|
||
{
|
||
System_IO_FileStream_FlushI(this->_p , flushToDisk);
|
||
}
|
||
};
|
||
class BinaryReader
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
BinaryReader(MemoryStream& ms)
|
||
{
|
||
this->_p = System_IO_BinaryReader_New(ms._p);
|
||
}
|
||
BinaryReader(FileStream& fs)
|
||
{
|
||
this->_p = System_IO_BinaryReader_NewI(fs._p);
|
||
}
|
||
BinaryReader(Stream& stream)
|
||
{
|
||
this->_p = System_IO_BinaryReader_NewII(stream._p);
|
||
}
|
||
byte ReadByte()
|
||
{
|
||
return System_IO_BinaryReader_ReadByte(this->_p);
|
||
}
|
||
char ReadChar()
|
||
{
|
||
return System_IO_BinaryReader_ReadChar(this->_p);
|
||
}
|
||
Int16 ReadInt16()
|
||
{
|
||
return System_IO_BinaryReader_ReadInt16(this->_p);
|
||
}
|
||
UInt16 ReadUInt16()
|
||
{
|
||
return System_IO_BinaryReader_ReadUInt16(this->_p);
|
||
}
|
||
Int32 ReadInt32()
|
||
{
|
||
return System_IO_BinaryReader_ReadInt32(this->_p);
|
||
}
|
||
UInt32 ReadUInt32()
|
||
{
|
||
return System_IO_BinaryReader_ReadUInt32(this->_p);
|
||
}
|
||
Int64 ReadInt64()
|
||
{
|
||
return System_IO_BinaryReader_ReadInt64(this->_p);
|
||
}
|
||
UInt64 ReadUInt64()
|
||
{
|
||
return System_IO_BinaryReader_ReadUInt64(this->_p);
|
||
}
|
||
IntPtr ReadBytes(int len)
|
||
{
|
||
return System_IO_BinaryReader_ReadBytes(this->_p , len);
|
||
}
|
||
};
|
||
class BinaryWriter
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
BinaryWriter(MemoryStream& ms)
|
||
{
|
||
this->_p = System_IO_BinaryWriter_New(ms._p);
|
||
}
|
||
BinaryWriter(FileStream& fs)
|
||
{
|
||
this->_p = System_IO_BinaryWriter_NewI(fs._p);
|
||
}
|
||
BinaryWriter(Stream& stream)
|
||
{
|
||
this->_p = System_IO_BinaryWriter_NewII(stream._p);
|
||
}
|
||
void Write(bool b)
|
||
{
|
||
System_IO_BinaryWriter_WriteI(this->_p , b);
|
||
}
|
||
void Write(byte b)
|
||
{
|
||
System_IO_BinaryWriter_WriteII(this->_p , b);
|
||
}
|
||
void Write(Int16 v)
|
||
{
|
||
System_IO_BinaryWriter_WriteIII(this->_p , v);
|
||
}
|
||
void Write(Int32 v)
|
||
{
|
||
System_IO_BinaryWriter_WriteIV(this->_p , v);
|
||
}
|
||
void Write(Int64 v)
|
||
{
|
||
System_IO_BinaryWriter_WriteV(this->_p , v);
|
||
}
|
||
void Write(float v)
|
||
{
|
||
System_IO_BinaryWriter_WriteVI(this->_p , v);
|
||
}
|
||
void Write(double v)
|
||
{
|
||
System_IO_BinaryWriter_WriteVII(this->_p , v);
|
||
}
|
||
void Write(IntPtr buffer , int len)
|
||
{
|
||
System_IO_BinaryWriter_WriteVIII(this->_p , buffer , len);
|
||
}
|
||
|
||
};
|
||
class File
|
||
{
|
||
public:
|
||
static bool Exists(const char* path)
|
||
{
|
||
return System_IO_File_Exists(path);
|
||
}
|
||
static void Delete(const char* path)
|
||
{
|
||
System_IO_File_Delete(path);
|
||
}
|
||
static char* ReadAllText(const char* path)
|
||
{
|
||
return System_IO_File_ReadAllText(path);
|
||
}
|
||
static BYTE* ReadAllBytes(const char* path)
|
||
{
|
||
return System_IO_File_ReadAllBytes(path);
|
||
}
|
||
|
||
static void WriteAllText(const char* path , const char* text)
|
||
{
|
||
System_IO_File_WriteAllText(path , text);
|
||
}
|
||
static void WriteAllBytes(const char* path , BYTE* buffer , int len)
|
||
{
|
||
System_IO_File_WriteAllBytes(path , buffer , len);
|
||
}
|
||
static void AppendAllText(const char* path , const char* text)
|
||
{
|
||
System_IO_File_AppendAllText(path , text);
|
||
}
|
||
static INT64 GetSize(const char* path)
|
||
{
|
||
return System_IO_File_GetSize(path);
|
||
}
|
||
};
|
||
class Directory
|
||
{
|
||
public:
|
||
static void Delete(const char* path)
|
||
{
|
||
return System_IO_Directory_Delete(path);
|
||
}
|
||
static void Create(const char* path)
|
||
{
|
||
return System_IO_Directory_CreateDirectory(path);
|
||
}
|
||
static bool Exists(const char* path)
|
||
{
|
||
return System_IO_Directory_Exists(path);
|
||
}
|
||
static vector<char*> GetFiles(const char* path)
|
||
{
|
||
int len = 0;
|
||
auto ps = System_IO_Directory_GetFiles(path , &len);
|
||
vector<char*> result;
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
result.push_back(ps[i]);
|
||
}
|
||
return result;
|
||
}
|
||
static vector<char*> GetDirectories(const char* path)
|
||
{
|
||
int len = 0;
|
||
auto ps = System_IO_Directory_GetDirectories(path , &len);
|
||
vector<char*> result;
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
result.push_back(ps[i]);
|
||
}
|
||
return result;
|
||
}
|
||
};
|
||
namespace Compression
|
||
{
|
||
class Compress
|
||
{
|
||
public:
|
||
static BYTE* DoCompress(BYTE* val , int len , int* o_len)
|
||
{
|
||
return System_IO_Compression_Compress(val , len , o_len);
|
||
}
|
||
static BYTE* Decompress(BYTE* val , int len , int* o_len)
|
||
{
|
||
return System_IO_Compression_Decompress(val , len , o_len);
|
||
}
|
||
};
|
||
}
|
||
}
|
||
namespace Diagnostics
|
||
{
|
||
using namespace System::IO;
|
||
class Stopwatch
|
||
{
|
||
//private:
|
||
// tf;
|
||
//public:
|
||
// static Stopwatch* StartNew()
|
||
// {
|
||
// Stopwatch* st = new Stopwatch();
|
||
// st->stf = System_Diagnostics_Stopwatch_StartNew();
|
||
// return st;
|
||
// }
|
||
// ~Stopwatch()
|
||
// {
|
||
// System_IntPtr_Free(this->stf);
|
||
// }
|
||
// TimeSpan Elapsed()
|
||
// {
|
||
// INT64 v = System_Diagnostics_Stopwatch_Elapsed(stf);
|
||
// TimeSpan tm = TimeSpan(v);
|
||
// return tm;
|
||
// }
|
||
// void Stop()
|
||
// {
|
||
// System_Diagnostics_Stopwatch_Stop(stf);
|
||
// }
|
||
// void Restart()
|
||
// {
|
||
// System_Diagnostics_Stopwatch_Restart(stf);
|
||
// }
|
||
static long long toInteger(LARGE_INTEGER const& integer)
|
||
{
|
||
#ifdef INT64_MAX
|
||
return integer.QuadPart;
|
||
#else
|
||
return (static_cast<long long>(integer.HighPart) << 32) | integer.LowPart;
|
||
#endif
|
||
}
|
||
static LARGE_INTEGER toLargeInteger(long long value)
|
||
{
|
||
LARGE_INTEGER result;
|
||
|
||
#ifdef INT64_MAX
|
||
result.QuadPart = value;
|
||
#else
|
||
result.high_part = value & 0xFFFFFFFF00000000;
|
||
result.low_part = value & 0xFFFFFFFF;
|
||
#endif
|
||
return result;
|
||
}
|
||
public:
|
||
BOOLEAN RUNNING = false;
|
||
LARGE_INTEGER starttime;
|
||
LARGE_INTEGER endtime;
|
||
static Stopwatch* StartNew()
|
||
{
|
||
Stopwatch* st = new Stopwatch();
|
||
QueryPerformanceCounter(&st->starttime);
|
||
st->RUNNING = true;
|
||
return st;
|
||
}
|
||
TimeSpan Elapsed()
|
||
{
|
||
if(this->RUNNING)
|
||
{
|
||
LARGE_INTEGER _endtime;
|
||
QueryPerformanceCounter(&_endtime);
|
||
INT64 v = toInteger(_endtime) - toInteger(starttime);
|
||
TimeSpan tm = TimeSpan(v);
|
||
return tm;
|
||
}
|
||
else
|
||
{
|
||
INT64 v = toInteger(endtime) - toInteger(starttime);
|
||
TimeSpan tm = TimeSpan(v);
|
||
return tm;
|
||
}
|
||
}
|
||
void Stop()
|
||
{
|
||
this->RUNNING = false;
|
||
QueryPerformanceCounter(&this->endtime);
|
||
}
|
||
void Restart()
|
||
{
|
||
this->RUNNING = true;
|
||
QueryPerformanceCounter(&this->starttime);
|
||
}
|
||
};
|
||
class ProcessStartInfo
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
ProcessStartInfo(int)
|
||
{ }
|
||
ProcessStartInfo()
|
||
{
|
||
this->_p = System_Diagnostics_ProcessStartInfo_New();
|
||
}
|
||
ProcessStartInfo(const char* _filename)
|
||
{
|
||
this->_p = System_Diagnostics_ProcessStartInfo_NewI(_filename);
|
||
}
|
||
ProcessStartInfo(const char* _fileName , const char* _arguments)
|
||
{
|
||
this->_p = System_Diagnostics_ProcessStartInfo_NewII(_fileName , _arguments);
|
||
}
|
||
IntPtr GetFileName()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetFileName(this->_p);
|
||
}
|
||
void SetFileName(const char* filename)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetFileName(this->_p , filename);
|
||
}
|
||
char* GetArguments()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetArguments(this->_p);
|
||
}
|
||
void SetArguments(const char* Arguments)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetArguments(this->_p , Arguments);
|
||
}
|
||
bool GetCreateNoWindow()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetCreateNoWindow(this->_p);
|
||
}
|
||
void SetCreateNoWindow(bool CreateNoWindow)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetCreateNoWindow(this->_p , CreateNoWindow);
|
||
}
|
||
bool GetUseShellExecute()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetUseShellExecute(this->_p);
|
||
}
|
||
void SetUseShellExecute(bool UseShellExecute)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetUseShellExecute(this->_p , UseShellExecute);
|
||
}
|
||
bool GetRedirectStandardInput()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetRedirectStandardInput(this->_p);
|
||
}
|
||
void SetRedirectStandardInput(bool RedirectStandardInput)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetRedirectStandardInput(this->_p , RedirectStandardInput);
|
||
}
|
||
bool GetRedirectStandardOutput()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetRedirectStandardOutput(this->_p);
|
||
}
|
||
void SetRedirectStandardOutput(bool RedirectStandardOutput)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetRedirectStandardOutput(this->_p , RedirectStandardOutput);
|
||
}
|
||
bool GetRedirectStandardError()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetRedirectStandardError(this->_p);
|
||
}
|
||
void SetRedirectStandardError(bool RedirectStandardError)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetRedirectStandardError(this->_p , RedirectStandardError);
|
||
}
|
||
bool GetLoadUserProfile()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetLoadUserProfile(this->_p);
|
||
}
|
||
void SetLoadUserProfile(bool LoadUserProfile)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetLoadUserProfile(this->_p , LoadUserProfile);
|
||
}
|
||
char* _GetUserName()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetUserName(this->_p);
|
||
}
|
||
void _SetUserName(const char* UserName)
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_SetUserName(this->_p , UserName);
|
||
}
|
||
IntPtr GetVerb()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetVerb(this->_p);
|
||
}
|
||
void SetVerb(const char* Verb)
|
||
{
|
||
System_Diagnostics_ProcessStartInfo_SetVerb(this->_p , Verb);
|
||
}
|
||
ProcessWindowStyle GetWindowStyle()
|
||
{
|
||
return System_Diagnostics_ProcessStartInfo_GetWindowStyle(this->_p);
|
||
}
|
||
void SetWindowStyle(ProcessWindowStyle WindowStyle)
|
||
{
|
||
System_Diagnostics_ProcessStartInfo_SetWindowStyle(this->_p , WindowStyle);
|
||
}
|
||
};
|
||
class Process
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
Process(int)
|
||
{
|
||
//this->_p = System_Diagnostics_Process_New();
|
||
}
|
||
Process()
|
||
{
|
||
this->_p = System_Diagnostics_Process_New();
|
||
}
|
||
~Process()
|
||
{
|
||
System_IntPtr_Free(this->_p);
|
||
}
|
||
bool Start()
|
||
{
|
||
return System_Diagnostics_Process_StartII(this->_p);
|
||
}
|
||
void Close()
|
||
{
|
||
System_Diagnostics_Process_Close(this->_p);
|
||
}
|
||
static Process* Start(const char* path)
|
||
{
|
||
Process* result = new Process();
|
||
result->_p = System_Diagnostics_Process_Start(path);
|
||
}
|
||
static Process* Start(const char* path , const char* arguments)
|
||
{
|
||
Process* result = new Process();
|
||
result->_p = System_Diagnostics_Process_StartI(path , arguments);
|
||
}
|
||
static Process* GetProcessById(int pid)
|
||
{
|
||
Process* result = new Process(0);
|
||
result->_p = System_Diagnostics_Process_GetProcessById(pid);
|
||
return result;
|
||
}
|
||
static Process* GetCurrentProcess()
|
||
{
|
||
Process* result = new Process(0);
|
||
result->_p = System_Diagnostics_Process_GetCurrentProcess();
|
||
return result;
|
||
}
|
||
static void EnterDebugMode()
|
||
{
|
||
return System_Diagnostics_Process_EnterDebugMode();
|
||
}
|
||
static vector<Process*> GetProcesses()
|
||
{
|
||
vector<Process*> result;
|
||
int len = 0;
|
||
auto res = System_Diagnostics_Process_GetProcesses(&len);
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
auto pp = new Process(0);
|
||
pp->_p = res[i];
|
||
result.push_back(pp);
|
||
}
|
||
return result;
|
||
}
|
||
static vector<Process*> GetProcesses(const char* machineName)
|
||
{
|
||
vector<Process*> result;
|
||
int len = 0;
|
||
auto res = System_Diagnostics_Process_GetProcessesI(machineName , &len);
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
auto pp = new Process(0);
|
||
pp->_p = res[i];
|
||
result.push_back(pp);
|
||
}
|
||
return result;
|
||
}
|
||
static vector<Process*> GetProcessesByName(const char* processName)
|
||
{
|
||
vector<Process*> result;
|
||
int len = 0;
|
||
auto res = System_Diagnostics_Process_GetProcessesByName(processName , &len);
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
auto pp = new Process(0);
|
||
pp->_p = res[i];
|
||
result.push_back(pp);
|
||
}
|
||
return result;
|
||
}
|
||
System::IO::StreamReader* StandardError()
|
||
{
|
||
StreamReader* result = new StreamReader(0);
|
||
result->_p = System_Diagnostics_Process_StandardError(this->_p);
|
||
return result;
|
||
}
|
||
System::IO::StreamWriter* StandardInput()
|
||
{
|
||
StreamWriter* result = new StreamWriter(0);
|
||
result->_p = System_Diagnostics_Process_StandardInput(this->_p);
|
||
return result;
|
||
}
|
||
System::IO::StreamReader* StandardOutput()
|
||
{
|
||
StreamReader* result = new StreamReader(0);
|
||
result->_p = System_Diagnostics_Process_StandardOutput(this->_p);
|
||
return result;
|
||
}
|
||
ProcessStartInfo* StartInfo()
|
||
{
|
||
ProcessStartInfo* result = new ProcessStartInfo(0);
|
||
result->_p = System_Diagnostics_Process_StartInfo(this->_p);
|
||
return result;
|
||
}
|
||
void Kill()
|
||
{
|
||
System_Diagnostics_Process_Kill(this->_p);
|
||
}
|
||
void Kill(bool entireProcessTree)
|
||
{
|
||
System_Diagnostics_Process_KillI(this->_p , entireProcessTree);
|
||
}
|
||
void Refresh()
|
||
{
|
||
System_Diagnostics_Process_Refresh(this->_p);
|
||
}
|
||
void WaitForExit()
|
||
{
|
||
System_Diagnostics_Process_WaitForExit(this->_p);
|
||
}
|
||
bool WaitForExit(int milliseconds)
|
||
{
|
||
return System_Diagnostics_Process_WaitForExitI(this->_p , milliseconds);
|
||
}
|
||
void WaitForInputIdle()
|
||
{
|
||
System_Diagnostics_Process_WaitForInputIdle(this->_p);
|
||
}
|
||
bool WaitForInputIdle(int milliseconds)
|
||
{
|
||
return System_Diagnostics_Process_WaitForInputIdleI(this->_p , milliseconds);
|
||
}
|
||
int BasePriority()
|
||
{
|
||
return System_Diagnostics_Process_BasePriority(this->_p);
|
||
}
|
||
bool GetEnableRaisingEvents()
|
||
{
|
||
return System_Diagnostics_Process_GetEnableRaisingEvents(this->_p);
|
||
}
|
||
void SetEnableRaisingEvents(bool v)
|
||
{
|
||
return System_Diagnostics_Process_SetEnableRaisingEvents(this->_p , v);
|
||
}
|
||
int ExitCode()
|
||
{
|
||
return System_Diagnostics_Process_ExitCode(this->_p);
|
||
}
|
||
__DateTime ExitTime()
|
||
{
|
||
return System_Diagnostics_Process_ExitTime(this->_p);
|
||
}
|
||
IntPtr Handle()
|
||
{
|
||
return System_Diagnostics_Process_Handle(this->_p);
|
||
}
|
||
int HandleCount()
|
||
{
|
||
return System_Diagnostics_Process_HandleCount(this->_p);
|
||
}
|
||
bool HasExited()
|
||
{
|
||
return System_Diagnostics_Process_HasExited(this->_p);
|
||
}
|
||
int Id()
|
||
{
|
||
return System_Diagnostics_Process_Id(this->_p);
|
||
}
|
||
char* MachineName()
|
||
{
|
||
return System_Diagnostics_Process_MachineName(this->_p);
|
||
}
|
||
vector<_ProcessModule*> Modules()
|
||
{
|
||
int len = 0;
|
||
var mds = System_Diagnostics_Process_Modules(this->_p , &len);
|
||
vector<_ProcessModule*> result;
|
||
for(int i = 0; i < len; i++)
|
||
{
|
||
result.push_back(&mds[i]);
|
||
}
|
||
return result;
|
||
}
|
||
_ProcessModule* MainModule()
|
||
{
|
||
return System_Diagnostics_Process_MainModule(this->_p);
|
||
}
|
||
IntPtr MainWindowHandle()
|
||
{
|
||
return System_Diagnostics_Process_MainWindowHandle(this->_p);
|
||
}
|
||
char* MainWindowTitle()
|
||
{
|
||
return System_Diagnostics_Process_MainWindowTitle(this->_p);
|
||
}
|
||
IntPtr MaxWorkingSet()
|
||
{
|
||
return System_Diagnostics_Process_MaxWorkingSet(this->_p);
|
||
}
|
||
IntPtr MinWorkingSet()
|
||
{
|
||
return System_Diagnostics_Process_MinWorkingSet(this->_p);
|
||
}
|
||
long NonpagedSystemMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_NonpagedSystemMemorySize64(this->_p);
|
||
}
|
||
long PagedMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_PagedMemorySize64(this->_p);
|
||
}
|
||
long PagedSystemMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_PagedSystemMemorySize64(this->_p);
|
||
}
|
||
long PeakPagedMemorySize64(IntPtr process)
|
||
{
|
||
return System_Diagnostics_Process_PeakPagedMemorySize64(this->_p);
|
||
}
|
||
long PeakVirtualMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_PeakVirtualMemorySize64(this->_p);
|
||
}
|
||
long PeakWorkingSet64()
|
||
{
|
||
return System_Diagnostics_Process_PeakWorkingSet64(this->_p);
|
||
}
|
||
bool PriorityBoostEnabled()
|
||
{
|
||
return System_Diagnostics_Process_PriorityBoostEnabled(this->_p);
|
||
}
|
||
ProcessPriorityClass PriorityClass()
|
||
{
|
||
return System_Diagnostics_Process_PriorityClass(this->_p);
|
||
}
|
||
long PrivateMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_PrivateMemorySize64(this->_p);
|
||
}
|
||
TimeSpan PrivilegedProcessorTime()
|
||
{
|
||
return System_Diagnostics_Process_PrivilegedProcessorTime(this->_p);
|
||
}
|
||
char* ProcessName()
|
||
{
|
||
return System_Diagnostics_Process_ProcessName(this->_p);
|
||
}
|
||
IntPtr ProcessorAffinity()
|
||
{
|
||
return System_Diagnostics_Process_ProcessorAffinity(this->_p);
|
||
}
|
||
bool Responding()
|
||
{
|
||
return System_Diagnostics_Process_Responding(this->_p);
|
||
}
|
||
int SessionId()
|
||
{
|
||
return System_Diagnostics_Process_SessionId(this->_p);
|
||
}
|
||
__DateTime StartTime()
|
||
{
|
||
return System_Diagnostics_Process_StartTime(this->_p);
|
||
}
|
||
ThreadInfo* Threads(int* tlen)
|
||
{
|
||
return System_Diagnostics_Process_Threads(this->_p , tlen);
|
||
}
|
||
TimeSpan TotalProcessorTime()
|
||
{
|
||
return System_Diagnostics_Process_TotalProcessorTime(this->_p);
|
||
}
|
||
TimeSpan UserProcessorTime()
|
||
{
|
||
return System_Diagnostics_Process_UserProcessorTime(this->_p);
|
||
}
|
||
long VirtualMemorySize64()
|
||
{
|
||
return System_Diagnostics_Process_VirtualMemorySize64(this->_p);
|
||
}
|
||
long WorkingSet64()
|
||
{
|
||
return System_Diagnostics_Process_WorkingSet64(this->_p);
|
||
}
|
||
};
|
||
}
|
||
namespace Drawing
|
||
{
|
||
using namespace System::IO;
|
||
class Bitmap
|
||
{
|
||
public:
|
||
IntPtr _bmp;
|
||
BitmapData _bmpdata;
|
||
int Width;
|
||
int Height;
|
||
Bitmap()
|
||
{}
|
||
Bitmap(int wid , int hei)
|
||
{
|
||
this->_bmp = System_Drawing_Bitmap_New(wid , hei);
|
||
_bmpdata = this->Lock();
|
||
this->Width = _bmpdata.width;
|
||
this->Height = _bmpdata.height;
|
||
this->UnLock();
|
||
}
|
||
Bitmap(const char* path)
|
||
{
|
||
this->_bmp = System_Drawing_Bitmap_NewI(path);
|
||
_bmpdata = this->Lock();
|
||
this->Width = _bmpdata.width;
|
||
this->Height = _bmpdata.height;
|
||
this->UnLock();
|
||
}
|
||
Bitmap(MemoryStream* ms)
|
||
{
|
||
auto buffer = ms->ToArray();
|
||
BITMAPFILEHEADER* bmfh;
|
||
bmfh = (BITMAPFILEHEADER*)buffer;
|
||
BITMAPINFOHEADER* bmih;
|
||
bmih = (BITMAPINFOHEADER*)(buffer + sizeof(BITMAPFILEHEADER));
|
||
BITMAPINFO* bmi;
|
||
bmi = (BITMAPINFO*)bmih;
|
||
PVOID bits;
|
||
bits = (void*)(buffer + bmfh->bfOffBits);
|
||
HDC hdc = GetDC(NULL);
|
||
HBITMAP hbmp = CreateDIBitmap(hdc , bmih , CBM_INIT , bits , bmi , DIB_RGB_COLORS);
|
||
this->_bmp = System_Drawing_Bitmap_NewIII(hbmp);
|
||
_bmpdata = this->Lock();
|
||
this->Width = _bmpdata.width;
|
||
this->Height = _bmpdata.height;
|
||
this->UnLock();
|
||
}
|
||
~Bitmap()
|
||
{
|
||
System_IntPtr_Free(this->_bmp);
|
||
}
|
||
static Bitmap* FromHBITMAP(IntPtr p)
|
||
{
|
||
auto bm = System_Drawing_Bitmap_NewIII(p);
|
||
Bitmap* bmp = new Bitmap();
|
||
bmp->_bmp = bm;
|
||
return bmp;
|
||
}
|
||
BitmapData Lock()
|
||
{
|
||
this->_bmpdata = System_Drawing_Bitmap_Lock(this->_bmp);
|
||
return this->_bmpdata;
|
||
}
|
||
void UnLock()
|
||
{
|
||
System_Drawing_Bitmap_UnLock(this->_bmp , this->_bmpdata);
|
||
}
|
||
void Save(const char* path)
|
||
{
|
||
System_Drawing_Bitmap_Save(this->_bmp , path);
|
||
}
|
||
BOOL Save(MemoryStream* ms)
|
||
{
|
||
HBITMAP hBitmap = (HBITMAP)this->GetHbitmap();
|
||
HDC hDC;
|
||
int iBits;
|
||
WORD wBitCount;
|
||
DWORD dwPaletteSize = 0 , dwBmBitsSize = 0 , dwDIBSize = 0 , dwWritten = 0;
|
||
BITMAP Bitmap;
|
||
BITMAPFILEHEADER bmfHdr;
|
||
BITMAPINFOHEADER bi;
|
||
LPBITMAPINFOHEADER lpbi;
|
||
HANDLE hDib , hPal , hOldPal = NULL;
|
||
hDC = CreateDC(L"DISPLAY" , NULL , NULL , NULL);
|
||
iBits = GetDeviceCaps(hDC , BITSPIXEL) * GetDeviceCaps(hDC , PLANES);
|
||
DeleteDC(hDC);
|
||
if(iBits <= 1)
|
||
wBitCount = 1;
|
||
else if(iBits <= 4)
|
||
wBitCount = 4;
|
||
else if(iBits <= 8)
|
||
wBitCount = 8;
|
||
else
|
||
wBitCount = 24;
|
||
GetObject(hBitmap , sizeof(Bitmap) , (LPSTR)&Bitmap);
|
||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||
bi.biWidth = Bitmap.bmWidth;
|
||
bi.biHeight = Bitmap.bmHeight;
|
||
bi.biPlanes = 1;
|
||
bi.biBitCount = wBitCount;
|
||
bi.biCompression = BI_RGB;
|
||
bi.biSizeImage = 0;
|
||
bi.biXPelsPerMeter = 0;
|
||
bi.biYPelsPerMeter = 0;
|
||
bi.biClrImportant = 0;
|
||
bi.biClrUsed = 0;
|
||
dwBmBitsSize = ((Bitmap.bmWidth * wBitCount + 31) / 32) * 4 * Bitmap.bmHeight;
|
||
hDib = GlobalAlloc(GHND , dwBmBitsSize + dwPaletteSize + sizeof(BITMAPINFOHEADER));
|
||
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDib);
|
||
*lpbi = bi;
|
||
hPal = GetStockObject(DEFAULT_PALETTE);
|
||
if(hPal)
|
||
{
|
||
hDC = GetDC(NULL);
|
||
hOldPal = SelectPalette(hDC , (HPALETTE)hPal , FALSE);
|
||
RealizePalette(hDC);
|
||
}
|
||
GetDIBits(hDC , hBitmap , 0 , (UINT)Bitmap.bmHeight ,
|
||
(LPSTR)lpbi + sizeof(BITMAPINFOHEADER) + dwPaletteSize ,
|
||
(BITMAPINFO*)lpbi , DIB_RGB_COLORS);
|
||
if(hOldPal)
|
||
{
|
||
SelectPalette(hDC , (HPALETTE)hOldPal , TRUE);
|
||
RealizePalette(hDC);
|
||
ReleaseDC(NULL , hDC);
|
||
}
|
||
bmfHdr.bfType = 0x4D42; //"BM"
|
||
dwDIBSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + dwPaletteSize + dwBmBitsSize;
|
||
bmfHdr.bfSize = dwDIBSize;
|
||
bmfHdr.bfReserved1 = 0;
|
||
bmfHdr.bfReserved2 = 0;
|
||
bmfHdr.bfOffBits = (DWORD)sizeof(BITMAPFILEHEADER) + (DWORD)sizeof(BITMAPINFOHEADER) + dwPaletteSize;
|
||
ms->Write((BYTE*)&bmfHdr , sizeof(BITMAPFILEHEADER));
|
||
ms->Write((BYTE*)lpbi , dwDIBSize);
|
||
GlobalUnlock(hDib);
|
||
GlobalFree(hDib);
|
||
return TRUE;
|
||
|
||
}
|
||
int GetPixel(int x , int y)
|
||
{
|
||
return System_Drawing_Bitmap_GetPixel(this->_bmp , x , y);
|
||
}
|
||
void SetPixel(int x , int y , int c)
|
||
{
|
||
return System_Drawing_Bitmap_SetPixel(this->_bmp , x , y , c);
|
||
}
|
||
HANDLE GetHbitmap()
|
||
{
|
||
return System_Drawing_Bitmap_GetHbitmap(this->_bmp);
|
||
}
|
||
};
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD>ص<EFBFBD>ָ<EFBFBD>벻<EFBFBD><EBB2BB><EFBFBD>ͷţ<CDB7><C5A3>ͷź<CDB7><C5BA><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD>ʹ<EFBFBD>ø<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
||
/// </summary>
|
||
class Pens
|
||
{
|
||
public:
|
||
static IntPtr Transparent()
|
||
{
|
||
return System_Drawing_Pens_Transparent();
|
||
}
|
||
static IntPtr AliceBlue()
|
||
{
|
||
return System_Drawing_Pens_AliceBlue();
|
||
}
|
||
static IntPtr AntiqueWhite()
|
||
{
|
||
return System_Drawing_Pens_AntiqueWhite();
|
||
}
|
||
static IntPtr Aqua()
|
||
{
|
||
return System_Drawing_Pens_Aqua();
|
||
}
|
||
static IntPtr Aquamarine()
|
||
{
|
||
return System_Drawing_Pens_Aquamarine();
|
||
}
|
||
static IntPtr Azure()
|
||
{
|
||
return System_Drawing_Pens_Azure();
|
||
}
|
||
static IntPtr Beige()
|
||
{
|
||
return System_Drawing_Pens_Beige();
|
||
}
|
||
static IntPtr Bisque()
|
||
{
|
||
return System_Drawing_Pens_Bisque();
|
||
}
|
||
static IntPtr Black()
|
||
{
|
||
return System_Drawing_Pens_Black();
|
||
}
|
||
static IntPtr BlanchedAlmond()
|
||
{
|
||
return System_Drawing_Pens_BlanchedAlmond();
|
||
}
|
||
static IntPtr Blue()
|
||
{
|
||
return System_Drawing_Pens_Blue();
|
||
}
|
||
static IntPtr BlueViolet()
|
||
{
|
||
return System_Drawing_Pens_BlueViolet();
|
||
}
|
||
static IntPtr Brown()
|
||
{
|
||
return System_Drawing_Pens_Brown();
|
||
}
|
||
static IntPtr BurlyWood()
|
||
{
|
||
return System_Drawing_Pens_BurlyWood();
|
||
}
|
||
static IntPtr CadetBlue()
|
||
{
|
||
return System_Drawing_Pens_CadetBlue();
|
||
}
|
||
static IntPtr Chartreuse()
|
||
{
|
||
return System_Drawing_Pens_Chartreuse();
|
||
}
|
||
static IntPtr Chocolate()
|
||
{
|
||
return System_Drawing_Pens_Chocolate();
|
||
}
|
||
static IntPtr Coral()
|
||
{
|
||
return System_Drawing_Pens_Coral();
|
||
}
|
||
static IntPtr CornflowerBlue()
|
||
{
|
||
return System_Drawing_Pens_CornflowerBlue();
|
||
}
|
||
static IntPtr Cornsilk()
|
||
{
|
||
return System_Drawing_Pens_Cornsilk();
|
||
}
|
||
static IntPtr Crimson()
|
||
{
|
||
return System_Drawing_Pens_Crimson();
|
||
}
|
||
static IntPtr Cyan()
|
||
{
|
||
return System_Drawing_Pens_Cyan();
|
||
}
|
||
static IntPtr DarkBlue()
|
||
{
|
||
return System_Drawing_Pens_DarkBlue();
|
||
}
|
||
static IntPtr DarkCyan()
|
||
{
|
||
return System_Drawing_Pens_DarkCyan();
|
||
}
|
||
static IntPtr DarkGoldenrod()
|
||
{
|
||
return System_Drawing_Pens_DarkGoldenrod();
|
||
}
|
||
static IntPtr DarkGray()
|
||
{
|
||
return System_Drawing_Pens_DarkGray();
|
||
}
|
||
static IntPtr DarkGreen()
|
||
{
|
||
return System_Drawing_Pens_DarkGreen();
|
||
}
|
||
static IntPtr DarkKhaki()
|
||
{
|
||
return System_Drawing_Pens_DarkKhaki();
|
||
}
|
||
static IntPtr DarkMagenta()
|
||
{
|
||
return System_Drawing_Pens_DarkMagenta();
|
||
}
|
||
static IntPtr DarkOliveGreen()
|
||
{
|
||
return System_Drawing_Pens_DarkOliveGreen();
|
||
}
|
||
static IntPtr DarkOrange()
|
||
{
|
||
return System_Drawing_Pens_DarkOrange();
|
||
}
|
||
static IntPtr DarkOrchid()
|
||
{
|
||
return System_Drawing_Pens_DarkOrchid();
|
||
}
|
||
static IntPtr DarkRed()
|
||
{
|
||
return System_Drawing_Pens_DarkRed();
|
||
}
|
||
static IntPtr DarkSalmon()
|
||
{
|
||
return System_Drawing_Pens_DarkSalmon();
|
||
}
|
||
static IntPtr DarkSeaGreen()
|
||
{
|
||
return System_Drawing_Pens_DarkSeaGreen();
|
||
}
|
||
static IntPtr DarkSlateBlue()
|
||
{
|
||
return System_Drawing_Pens_DarkSlateBlue();
|
||
}
|
||
static IntPtr DarkSlateGray()
|
||
{
|
||
return System_Drawing_Pens_DarkSlateGray();
|
||
}
|
||
static IntPtr DarkTurquoise()
|
||
{
|
||
return System_Drawing_Pens_DarkTurquoise();
|
||
}
|
||
static IntPtr DarkViolet()
|
||
{
|
||
return System_Drawing_Pens_DarkViolet();
|
||
}
|
||
static IntPtr DeepPink()
|
||
{
|
||
return System_Drawing_Pens_DeepPink();
|
||
}
|
||
static IntPtr DeepSkyBlue()
|
||
{
|
||
return System_Drawing_Pens_DeepSkyBlue();
|
||
}
|
||
static IntPtr DimGray()
|
||
{
|
||
return System_Drawing_Pens_DimGray();
|
||
}
|
||
static IntPtr DodgerBlue()
|
||
{
|
||
return System_Drawing_Pens_DodgerBlue();
|
||
}
|
||
static IntPtr Firebrick()
|
||
{
|
||
return System_Drawing_Pens_Firebrick();
|
||
}
|
||
static IntPtr FloralWhite()
|
||
{
|
||
return System_Drawing_Pens_FloralWhite();
|
||
}
|
||
static IntPtr ForestGreen()
|
||
{
|
||
return System_Drawing_Pens_ForestGreen();
|
||
}
|
||
static IntPtr Fuchsia()
|
||
{
|
||
return System_Drawing_Pens_Fuchsia();
|
||
}
|
||
static IntPtr Gainsboro()
|
||
{
|
||
return System_Drawing_Pens_Gainsboro();
|
||
}
|
||
static IntPtr GhostWhite()
|
||
{
|
||
return System_Drawing_Pens_GhostWhite();
|
||
}
|
||
static IntPtr Gold()
|
||
{
|
||
return System_Drawing_Pens_Gold();
|
||
}
|
||
static IntPtr Goldenrod()
|
||
{
|
||
return System_Drawing_Pens_Goldenrod();
|
||
}
|
||
static IntPtr Gray()
|
||
{
|
||
return System_Drawing_Pens_Gray();
|
||
}
|
||
static IntPtr Green()
|
||
{
|
||
return System_Drawing_Pens_Green();
|
||
}
|
||
static IntPtr GreenYellow()
|
||
{
|
||
return System_Drawing_Pens_GreenYellow();
|
||
}
|
||
static IntPtr Honeydew()
|
||
{
|
||
return System_Drawing_Pens_Honeydew();
|
||
}
|
||
static IntPtr HotPink()
|
||
{
|
||
return System_Drawing_Pens_HotPink();
|
||
}
|
||
static IntPtr IndianRed()
|
||
{
|
||
return System_Drawing_Pens_IndianRed();
|
||
}
|
||
static IntPtr Indigo()
|
||
{
|
||
return System_Drawing_Pens_Indigo();
|
||
}
|
||
static IntPtr Ivory()
|
||
{
|
||
return System_Drawing_Pens_Ivory();
|
||
}
|
||
static IntPtr Khaki()
|
||
{
|
||
return System_Drawing_Pens_Khaki();
|
||
}
|
||
static IntPtr Lavender()
|
||
{
|
||
return System_Drawing_Pens_Lavender();
|
||
}
|
||
static IntPtr LavenderBlush()
|
||
{
|
||
return System_Drawing_Pens_LavenderBlush();
|
||
}
|
||
static IntPtr LawnGreen()
|
||
{
|
||
return System_Drawing_Pens_LawnGreen();
|
||
}
|
||
static IntPtr LemonChiffon()
|
||
{
|
||
return System_Drawing_Pens_LemonChiffon();
|
||
}
|
||
static IntPtr LightBlue()
|
||
{
|
||
return System_Drawing_Pens_LightBlue();
|
||
}
|
||
static IntPtr LightCoral()
|
||
{
|
||
return System_Drawing_Pens_LightCoral();
|
||
}
|
||
static IntPtr LightCyan()
|
||
{
|
||
return System_Drawing_Pens_LightCyan();
|
||
}
|
||
static IntPtr LightGoldenrodYellow()
|
||
{
|
||
return System_Drawing_Pens_LightGoldenrodYellow();
|
||
}
|
||
static IntPtr LightGreen()
|
||
{
|
||
return System_Drawing_Pens_LightGreen();
|
||
}
|
||
static IntPtr LightGray()
|
||
{
|
||
return System_Drawing_Pens_LightGray();
|
||
}
|
||
static IntPtr LightPink()
|
||
{
|
||
return System_Drawing_Pens_LightPink();
|
||
}
|
||
static IntPtr LightSalmon()
|
||
{
|
||
return System_Drawing_Pens_LightSalmon();
|
||
}
|
||
static IntPtr LightSeaGreen()
|
||
{
|
||
return System_Drawing_Pens_LightSeaGreen();
|
||
}
|
||
static IntPtr LightSkyBlue()
|
||
{
|
||
return System_Drawing_Pens_LightSkyBlue();
|
||
}
|
||
static IntPtr LightSlateGray()
|
||
{
|
||
return System_Drawing_Pens_LightSlateGray();
|
||
}
|
||
static IntPtr LightSteelBlue()
|
||
{
|
||
return System_Drawing_Pens_LightSteelBlue();
|
||
}
|
||
static IntPtr LightYellow()
|
||
{
|
||
return System_Drawing_Pens_LightYellow();
|
||
}
|
||
static IntPtr Lime()
|
||
{
|
||
return System_Drawing_Pens_Lime();
|
||
}
|
||
static IntPtr LimeGreen()
|
||
{
|
||
return System_Drawing_Pens_LimeGreen();
|
||
}
|
||
static IntPtr Linen()
|
||
{
|
||
return System_Drawing_Pens_Linen();
|
||
}
|
||
static IntPtr Magenta()
|
||
{
|
||
return System_Drawing_Pens_Magenta();
|
||
}
|
||
static IntPtr Maroon()
|
||
{
|
||
return System_Drawing_Pens_Maroon();
|
||
}
|
||
static IntPtr MediumAquamarine()
|
||
{
|
||
return System_Drawing_Pens_MediumAquamarine();
|
||
}
|
||
static IntPtr MediumBlue()
|
||
{
|
||
return System_Drawing_Pens_MediumBlue();
|
||
}
|
||
static IntPtr MediumOrchid()
|
||
{
|
||
return System_Drawing_Pens_MediumOrchid();
|
||
}
|
||
static IntPtr MediumPurple()
|
||
{
|
||
return System_Drawing_Pens_MediumPurple();
|
||
}
|
||
static IntPtr MediumSeaGreen()
|
||
{
|
||
return System_Drawing_Pens_MediumSeaGreen();
|
||
}
|
||
static IntPtr MediumSlateBlue()
|
||
{
|
||
return System_Drawing_Pens_MediumSlateBlue();
|
||
}
|
||
static IntPtr MediumSpringGreen()
|
||
{
|
||
return System_Drawing_Pens_MediumSpringGreen();
|
||
}
|
||
static IntPtr MediumTurquoise()
|
||
{
|
||
return System_Drawing_Pens_MediumTurquoise();
|
||
}
|
||
static IntPtr MediumVioletRed()
|
||
{
|
||
return System_Drawing_Pens_MediumVioletRed();
|
||
}
|
||
static IntPtr MidnightBlue()
|
||
{
|
||
return System_Drawing_Pens_MidnightBlue();
|
||
}
|
||
static IntPtr MintCream()
|
||
{
|
||
return System_Drawing_Pens_MintCream();
|
||
}
|
||
static IntPtr MistyRose()
|
||
{
|
||
return System_Drawing_Pens_MistyRose();
|
||
}
|
||
static IntPtr Moccasin()
|
||
{
|
||
return System_Drawing_Pens_Moccasin();
|
||
}
|
||
static IntPtr NavajoWhite()
|
||
{
|
||
return System_Drawing_Pens_NavajoWhite();
|
||
}
|
||
static IntPtr Navy()
|
||
{
|
||
return System_Drawing_Pens_Navy();
|
||
}
|
||
static IntPtr OldLace()
|
||
{
|
||
return System_Drawing_Pens_OldLace();
|
||
}
|
||
static IntPtr Olive()
|
||
{
|
||
return System_Drawing_Pens_Olive();
|
||
}
|
||
static IntPtr OliveDrab()
|
||
{
|
||
return System_Drawing_Pens_OliveDrab();
|
||
}
|
||
static IntPtr Orange()
|
||
{
|
||
return System_Drawing_Pens_Orange();
|
||
}
|
||
static IntPtr OrangeRed()
|
||
{
|
||
return System_Drawing_Pens_OrangeRed();
|
||
}
|
||
static IntPtr Orchid()
|
||
{
|
||
return System_Drawing_Pens_Orchid();
|
||
}
|
||
static IntPtr PaleGoldenrod()
|
||
{
|
||
return System_Drawing_Pens_PaleGoldenrod();
|
||
}
|
||
static IntPtr PaleGreen()
|
||
{
|
||
return System_Drawing_Pens_PaleGreen();
|
||
}
|
||
static IntPtr PaleTurquoise()
|
||
{
|
||
return System_Drawing_Pens_PaleTurquoise();
|
||
}
|
||
static IntPtr PaleVioletRed()
|
||
{
|
||
return System_Drawing_Pens_PaleVioletRed();
|
||
}
|
||
static IntPtr PapayaWhip()
|
||
{
|
||
return System_Drawing_Pens_PapayaWhip();
|
||
}
|
||
static IntPtr PeachPuff()
|
||
{
|
||
return System_Drawing_Pens_PeachPuff();
|
||
}
|
||
static IntPtr Peru()
|
||
{
|
||
return System_Drawing_Pens_Peru();
|
||
}
|
||
static IntPtr Pink()
|
||
{
|
||
return System_Drawing_Pens_Pink();
|
||
}
|
||
static IntPtr Plum()
|
||
{
|
||
return System_Drawing_Pens_Plum();
|
||
}
|
||
static IntPtr PowderBlue()
|
||
{
|
||
return System_Drawing_Pens_PowderBlue();
|
||
}
|
||
static IntPtr Purple()
|
||
{
|
||
return System_Drawing_Pens_Purple();
|
||
}
|
||
static IntPtr Red()
|
||
{
|
||
return System_Drawing_Pens_Red();
|
||
}
|
||
static IntPtr RosyBrown()
|
||
{
|
||
return System_Drawing_Pens_RosyBrown();
|
||
}
|
||
static IntPtr RoyalBlue()
|
||
{
|
||
return System_Drawing_Pens_RoyalBlue();
|
||
}
|
||
static IntPtr SaddleBrown()
|
||
{
|
||
return System_Drawing_Pens_SaddleBrown();
|
||
}
|
||
static IntPtr Salmon()
|
||
{
|
||
return System_Drawing_Pens_Salmon();
|
||
}
|
||
static IntPtr SandyBrown()
|
||
{
|
||
return System_Drawing_Pens_SandyBrown();
|
||
}
|
||
static IntPtr SeaGreen()
|
||
{
|
||
return System_Drawing_Pens_SeaGreen();
|
||
}
|
||
static IntPtr SeaShell()
|
||
{
|
||
return System_Drawing_Pens_SeaShell();
|
||
}
|
||
static IntPtr Sienna()
|
||
{
|
||
return System_Drawing_Pens_Sienna();
|
||
}
|
||
static IntPtr Silver()
|
||
{
|
||
return System_Drawing_Pens_Silver();
|
||
}
|
||
static IntPtr SkyBlue()
|
||
{
|
||
return System_Drawing_Pens_SkyBlue();
|
||
}
|
||
static IntPtr SlateBlue()
|
||
{
|
||
return System_Drawing_Pens_SlateBlue();
|
||
}
|
||
static IntPtr SlateGray()
|
||
{
|
||
return System_Drawing_Pens_SlateGray();
|
||
}
|
||
static IntPtr Snow()
|
||
{
|
||
return System_Drawing_Pens_Snow();
|
||
}
|
||
static IntPtr SpringGreen()
|
||
{
|
||
return System_Drawing_Pens_SpringGreen();
|
||
}
|
||
static IntPtr SteelBlue()
|
||
{
|
||
return System_Drawing_Pens_SteelBlue();
|
||
}
|
||
static IntPtr Tan()
|
||
{
|
||
return System_Drawing_Pens_Tan();
|
||
}
|
||
static IntPtr Teal()
|
||
{
|
||
return System_Drawing_Pens_Teal();
|
||
}
|
||
static IntPtr Thistle()
|
||
{
|
||
return System_Drawing_Pens_Thistle();
|
||
}
|
||
static IntPtr Tomato()
|
||
{
|
||
return System_Drawing_Pens_Tomato();
|
||
}
|
||
static IntPtr Turquoise()
|
||
{
|
||
return System_Drawing_Pens_Turquoise();
|
||
}
|
||
static IntPtr Violet()
|
||
{
|
||
return System_Drawing_Pens_Violet();
|
||
}
|
||
static IntPtr Wheat()
|
||
{
|
||
return System_Drawing_Pens_Wheat();
|
||
}
|
||
static IntPtr White()
|
||
{
|
||
return System_Drawing_Pens_White();
|
||
}
|
||
static IntPtr WhiteSmoke()
|
||
{
|
||
return System_Drawing_Pens_WhiteSmoke();
|
||
}
|
||
static IntPtr Yellow()
|
||
{
|
||
return System_Drawing_Pens_Yellow();
|
||
}
|
||
static IntPtr YellowGreen()
|
||
{
|
||
return System_Drawing_Pens_YellowGreen();
|
||
}
|
||
};
|
||
class Font
|
||
{
|
||
public:
|
||
IntPtr ptr;
|
||
Font(const char* name , float size)
|
||
{
|
||
this->ptr = System_Drawing_Font_New(name , size);
|
||
}
|
||
};
|
||
class Graphics
|
||
{
|
||
public:
|
||
IntPtr _g;
|
||
static IntPtr NewPen(int argb , float wid)
|
||
{
|
||
return System_Drawing_Pen_New(argb , wid);
|
||
}
|
||
static Graphics* FromBitmap(Bitmap* bmp)
|
||
{
|
||
Graphics* g = new Graphics();
|
||
g->_g = System_Drawing_Graphics_FromBitmap(bmp->_bmp);
|
||
return g;
|
||
}
|
||
static Graphics* FromHdc(HDC hdc)
|
||
{
|
||
Graphics* g = new Graphics();
|
||
g->_g = System_Drawing_Graphics_FromHdc(hdc);
|
||
return g;
|
||
}
|
||
static Graphics* FromHwnd(HWND hwnd)
|
||
{
|
||
Graphics* g = new Graphics();
|
||
g->_g = System_Drawing_Graphics_FromHwnd(hwnd);
|
||
return g;
|
||
}
|
||
~Graphics()
|
||
{
|
||
System_IntPtr_Free(this->_g);
|
||
}
|
||
void Dispose()
|
||
{
|
||
this->~Graphics();
|
||
}
|
||
void CopyFromScreen(int sleft , int stop , int dleft , int dtop , int wid , int hei)
|
||
{
|
||
System_Drawing_Graphics_CopyFromScreen(this->_g , sleft , stop , dleft , dtop , wid , hei);
|
||
}
|
||
void CopyFromScreen(int sleft , int stop , int dleft , int dtop , SIZE siz)
|
||
{
|
||
System_Drawing_Graphics_CopyFromScreen(this->_g , sleft , stop , dleft , dtop , (int)siz.cx , (int)siz.cy);
|
||
}
|
||
void CopyFromScreen(POINT sourp , POINT destp , SIZE siz)
|
||
{
|
||
System_Drawing_Graphics_CopyFromScreen(this->_g , (int)sourp.x , (int)sourp.y , (int)destp.x , (int)destp.y , (int)siz.cx , (int)siz.cy);
|
||
}
|
||
void DrawLine(IntPtr pen , float x1 , float y1 , float x2 , float y2)
|
||
{
|
||
System_Drawing_Graphics_DrawLine(this->_g , pen , x1 , y1 , x2 , y2);
|
||
}
|
||
void DrawBezier(IntPtr pen , float x1 , float y1 , float x2 , float y2 , float x3 , float y3 , float x4 , float y4)
|
||
{
|
||
System_Drawing_Graphics_DrawBezier(this->_g , pen , x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4);
|
||
}
|
||
void DrawString(const char* s , IntPtr pen , Font* _fon , float x , float y)
|
||
{
|
||
System_Drawing_Graphics_DrawString(s , this->_g , pen , _fon->ptr , x , y);
|
||
}
|
||
void DrawString(const char* s , IntPtr pen , Font _fon , float x , float y)
|
||
{
|
||
System_Drawing_Graphics_DrawString(s , this->_g , pen , _fon.ptr , x , y);
|
||
}
|
||
_SizeF MeasureString(const char* s , Font _fon)
|
||
{
|
||
return System_Drawing_Graphics_MeasureString(s , this->_g , _fon.ptr);
|
||
}
|
||
_SizeF MeasureString(const char* s , Font* _fon)
|
||
{
|
||
return System_Drawing_Graphics_MeasureString(s , this->_g , _fon->ptr);
|
||
}
|
||
void DrawRectangle(IntPtr pen , float x , float y , float w , float h)
|
||
{
|
||
System_Drawing_Graphics_DrawRectangle(this->_g , pen , x , y , w , h);
|
||
}
|
||
void FillRectangle(IntPtr pen , float x , float y , float w , float h)
|
||
{
|
||
System_Drawing_Graphics_FillRectangle(this->_g , pen , x , y , w , h);
|
||
}
|
||
void DrawEllipse(IntPtr pen , float x , float y , float w , float h)
|
||
{
|
||
System_Drawing_Graphics_DrawEllipse(this->_g , pen , x , y , w , h);
|
||
}
|
||
void Fillllipse(IntPtr pen , float x , float y , float w , float h)
|
||
{
|
||
System_Drawing_Graphics_FillEllipse(this->_g , pen , x , y , w , h);
|
||
}
|
||
void DrawBitmap(Bitmap _b , float x , float y)
|
||
{
|
||
System_Drawing_Graphics_DrawBitmap(this->_g , _b._bmp , x , y);
|
||
}
|
||
void DrawBitmap(Bitmap* _b , float x , float y)
|
||
{
|
||
System_Drawing_Graphics_DrawBitmap(this->_g , _b->_bmp , x , y);
|
||
}
|
||
void DrawBitmap(Bitmap* _b , int x , int y , int w , int h , float x1 , float y1 , float w1 , float h1)
|
||
{
|
||
System_Drawing_Graphics_DrawBitmapII(this->_g , _b->_bmp , x , y , w , h , x1 , y1 , w1 , h1);
|
||
}
|
||
void DrawBitmap(Bitmap* _b , float x , float y , float wid , float hei)
|
||
{
|
||
System_Drawing_Graphics_DrawBitmapI(this->_g , _b->_bmp , x , y , wid , hei);
|
||
}
|
||
void Clear(int argb)
|
||
{
|
||
System_Drawing_Graphics_Clear(this->_g , argb);
|
||
}
|
||
};
|
||
}
|
||
namespace Windows
|
||
{
|
||
namespace Forms
|
||
{
|
||
using namespace System::Drawing;
|
||
enum MessageBoxButtomType
|
||
{
|
||
OK = 0x00000000L ,
|
||
OKCANCEL = 0x00000001L ,
|
||
ABORTRETRYIGNORE = 0x00000002L ,
|
||
YESNOCANCEL = 0x00000003L ,
|
||
YESNO = 0x00000004L ,
|
||
METRYCANCEL = 0x00000005L ,
|
||
CANCELTRYCONTINUE = 0x00000006L ,
|
||
};
|
||
#undef MessageBox
|
||
class MessageBox
|
||
{
|
||
public:
|
||
static int Show(const char* text , const char* caption = "<EFBFBD><EFBFBD>ʾ" , MessageBoxButtomType button = MessageBoxButtomType::OK)
|
||
{
|
||
return MessageBoxA(NULL , text , caption , button);
|
||
}
|
||
static int Show(HWND hwnd , const char* text , const char* caption = "<EFBFBD><EFBFBD>ʾ" , MessageBoxButtomType button = MessageBoxButtomType::OK)
|
||
{
|
||
return MessageBoxA(hwnd , text , caption , button);
|
||
}
|
||
};
|
||
class OpenFileDialog
|
||
{
|
||
public:
|
||
TCHAR* Title;
|
||
TCHAR* Filter;
|
||
char* FileName;
|
||
OpenFileDialog(const TCHAR* title = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>" , const TCHAR* filter = L"All File(*.*)\0*.*\0")
|
||
{
|
||
this->Title = (TCHAR*)title;
|
||
this->Filter = (TCHAR*)filter;
|
||
}
|
||
bool ShowDialog()
|
||
{
|
||
TCHAR szBuffer[MAX_PATH] = { 0 };
|
||
OPENFILENAME file = { 0 };
|
||
file.hwndOwner = NULL;
|
||
file.lpstrTitle = this->Title;
|
||
file.lStructSize = sizeof(file);
|
||
file.lpstrFilter = this->Filter;
|
||
file.lpstrFile = szBuffer;
|
||
file.nMaxFile = sizeof(szBuffer) / sizeof(*szBuffer);
|
||
file.nFilterIndex = 0;
|
||
file.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER;//<2F><>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>ѡҪ<D1A1><D2AA><EFBFBD><EFBFBD>OFN_ALLOWMULTISELECT
|
||
BOOL bSel = GetOpenFileName(&file);
|
||
this->FileName = TCHAR2char(szBuffer);
|
||
return bSel;
|
||
}
|
||
};
|
||
class SaveFileDialog
|
||
{
|
||
public:
|
||
TCHAR* Title;
|
||
TCHAR* Filter;
|
||
char* FileName;
|
||
SaveFileDialog(const TCHAR* title = L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>" , const TCHAR* filter = L"All File(*.*)\0*.*\0")
|
||
{
|
||
this->Title = (TCHAR*)title;
|
||
this->Filter = (TCHAR*)filter;
|
||
|
||
}
|
||
bool ShowDialog()
|
||
{
|
||
TCHAR szBuffer[MAX_PATH] = { 0 };
|
||
OPENFILENAME file = { 0 };
|
||
file.hwndOwner = NULL;
|
||
file.lpstrTitle = this->Title;
|
||
file.lStructSize = sizeof(file);
|
||
file.lpstrFilter = this->Filter;
|
||
file.lpstrFile = szBuffer;
|
||
file.nMaxFile = sizeof(szBuffer) / sizeof(*szBuffer);
|
||
file.nFilterIndex = 0;
|
||
file.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER;
|
||
BOOL bSel = GetSaveFileName(&file);
|
||
this->FileName = TCHAR2char(szBuffer);
|
||
return bSel;
|
||
}
|
||
};
|
||
class OpenFolderDialog
|
||
{
|
||
public:
|
||
TCHAR* Title;
|
||
char* SelectedPath;
|
||
OpenFolderDialog(const TCHAR* title = L"ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>")
|
||
{
|
||
this->Title = (TCHAR*)title;
|
||
}
|
||
bool ShowDialog()
|
||
{
|
||
TCHAR szBuffer[MAX_PATH] = { 0 };
|
||
BROWSEINFO bi = {};
|
||
ZeroMemory(&bi , sizeof(BROWSEINFO));
|
||
bi.hwndOwner = NULL;
|
||
bi.pszDisplayName = szBuffer;
|
||
bi.lpszTitle = this->Title;
|
||
bi.ulFlags = BIF_RETURNFSANCESTORS;
|
||
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
|
||
if(NULL == idl)
|
||
{
|
||
return false;
|
||
}
|
||
BOOL bSel = SHGetPathFromIDList(idl , szBuffer);
|
||
this->SelectedPath = TCHAR2char(szBuffer);
|
||
return bSel;
|
||
}
|
||
};
|
||
class Clipboard
|
||
{
|
||
public:
|
||
static BOOL SetText(const char* pstr)
|
||
{
|
||
if(OpenClipboard(NULL))
|
||
{
|
||
char* pBuf;
|
||
if(0 == EmptyClipboard())
|
||
{
|
||
CloseClipboard();
|
||
return false;
|
||
}
|
||
HANDLE hClip = GlobalAlloc(GMEM_MOVEABLE , strlen(pstr) + 1);
|
||
if(NULL == hClip)
|
||
{
|
||
CloseClipboard();
|
||
return false;
|
||
}
|
||
pBuf = (char*)GlobalLock(hClip);
|
||
if(NULL == pBuf)
|
||
{
|
||
CloseClipboard();
|
||
if(hClip)
|
||
{
|
||
CloseHandle(hClip);
|
||
}
|
||
return false;
|
||
}
|
||
memcpy(pBuf , pstr , strlen(pstr));
|
||
GlobalUnlock(hClip);
|
||
|
||
if(NULL == SetClipboardData(CF_TEXT , hClip))
|
||
{
|
||
CloseClipboard();
|
||
if(hClip)
|
||
{
|
||
CloseHandle(hClip);
|
||
}
|
||
return false;
|
||
}
|
||
CloseClipboard();
|
||
}
|
||
return true;
|
||
}
|
||
static BOOL SetBitmap(Bitmap* bmp)
|
||
{
|
||
HANDLE bitmap = bmp->GetHbitmap();
|
||
HBITMAP hBM = (HBITMAP)bitmap;
|
||
if(!OpenClipboard(NULL))
|
||
{
|
||
return false;
|
||
}
|
||
EmptyClipboard();
|
||
BITMAP bm;
|
||
GetObject(hBM , sizeof(bm) , &bm);
|
||
BITMAPINFOHEADER bi;
|
||
ZeroMemory(&bi , sizeof(BITMAPINFOHEADER));
|
||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||
bi.biWidth = bm.bmWidth;
|
||
bi.biHeight = bm.bmHeight;
|
||
bi.biPlanes = 1;
|
||
bi.biBitCount = bm.bmBitsPixel;
|
||
bi.biCompression = BI_RGB;
|
||
if(bi.biBitCount <= 1)
|
||
{
|
||
bi.biBitCount = 1;
|
||
}
|
||
else if(bi.biBitCount <= 4)
|
||
{
|
||
bi.biBitCount = 4;
|
||
}
|
||
else if(bi.biBitCount <= 8)
|
||
{
|
||
bi.biBitCount = 8;
|
||
}
|
||
else
|
||
{
|
||
bi.biBitCount = 24;
|
||
}
|
||
SIZE_T dwColTableLen = (bi.biBitCount <= 8) ? (1 << bi.biBitCount) * sizeof(RGBQUAD) : 0;
|
||
HDC hDC = ::GetDC(NULL);
|
||
HPALETTE hPal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
|
||
HPALETTE hOldPal = ::SelectPalette(hDC , hPal , FALSE);
|
||
RealizePalette(hDC);
|
||
GetDIBits(hDC , hBM , 0 , static_cast<UINT>(bi.biHeight) , NULL , (LPBITMAPINFO)&bi , DIB_RGB_COLORS);
|
||
if(0 == bi.biSizeImage)
|
||
{
|
||
bi.biSizeImage = ((((bi.biWidth * bi.biBitCount) + 31) & ~31) / 8) * bi.biHeight;
|
||
}
|
||
HGLOBAL hDIB = ::GlobalAlloc(GMEM_MOVEABLE , sizeof(BITMAPINFOHEADER) + dwColTableLen + bi.biSizeImage);
|
||
if(hDIB)
|
||
{
|
||
union tagHdr_u
|
||
{
|
||
LPVOID p;
|
||
LPBYTE pByte;
|
||
LPBITMAPINFOHEADER pHdr;
|
||
LPBITMAPINFO pInfo;
|
||
} Hdr;
|
||
|
||
Hdr.p = ::GlobalLock(hDIB);
|
||
CopyMemory(Hdr.p , &bi , sizeof(BITMAPINFOHEADER));
|
||
int nConv = GetDIBits(hDC , hBM , 0 , static_cast<UINT>(bi.biHeight) ,
|
||
Hdr.pByte + sizeof(BITMAPINFOHEADER) + dwColTableLen ,
|
||
Hdr.pInfo , DIB_RGB_COLORS);
|
||
GlobalUnlock(hDIB);
|
||
if(!nConv)
|
||
{
|
||
GlobalFree(hDIB);
|
||
hDIB = NULL;
|
||
}
|
||
}
|
||
if(hDIB)
|
||
{
|
||
SetClipboardData(CF_DIB , hDIB);
|
||
}
|
||
CloseClipboard();
|
||
SelectPalette(hDC , hOldPal , FALSE);
|
||
ReleaseDC(NULL , hDC);
|
||
return NULL != hDIB;
|
||
}
|
||
void Clear()
|
||
{
|
||
EmptyClipboard();
|
||
}
|
||
static char* GetText()
|
||
{
|
||
char* pstr = 0;
|
||
if(OpenClipboard(NULL))
|
||
{
|
||
if(IsClipboardFormatAvailable(CF_TEXT))
|
||
{
|
||
HANDLE hClip = GetClipboardData(CF_TEXT);
|
||
if(NULL == hClip)
|
||
{
|
||
CloseClipboard();
|
||
return 0;
|
||
}
|
||
pstr = (char*)GlobalLock(hClip);
|
||
GlobalUnlock(hClip);
|
||
CloseClipboard();
|
||
}
|
||
}
|
||
return pstr;
|
||
}
|
||
};
|
||
}
|
||
}
|
||
namespace Net
|
||
{
|
||
namespace Sockets
|
||
{
|
||
class Socket
|
||
{
|
||
public:
|
||
IntPtr _p;
|
||
Socket()
|
||
{ }
|
||
Socket(IntPtr handle)
|
||
{
|
||
this->_p = System_Net_Sockets_Socket_NewI(handle);
|
||
}
|
||
Socket(SocketType socketType , ProtocolType protocolType)
|
||
{
|
||
this->_p = System_Net_Sockets_Socket_NewII(socketType , protocolType);
|
||
}
|
||
~Socket()
|
||
{
|
||
System_IntPtr_Free(this->_p);
|
||
}
|
||
static bool SypportsIPv4()
|
||
{
|
||
return System_Net_Sockets_Socket_SupportsIPv4();
|
||
}
|
||
static bool SypportsIPv6()
|
||
{
|
||
return System_Net_Sockets_Socket_SupportsIPv6();
|
||
}
|
||
static bool SySupportsIPv6()
|
||
{
|
||
return System_Net_Sockets_Socket_OSSupportsIPv6();
|
||
}
|
||
static bool SySupportsUnixDomainSockets()
|
||
{
|
||
return System_Net_Sockets_Socket_OSSupportsUnixDomainSockets();
|
||
}
|
||
static bool SySupportsIPv4()
|
||
{
|
||
return System_Net_Sockets_Socket_OSSupportsIPv4();
|
||
}
|
||
char* RemoteEndPoint()
|
||
{
|
||
return System_Net_Sockets_Socket_RemoteEndPoint(this->_p);
|
||
}
|
||
IntPtr Handle()
|
||
{
|
||
return System_Net_Sockets_Socket_Handle(this->_p);
|
||
}
|
||
bool Synnected()
|
||
{
|
||
return System_Net_Sockets_Socket_Connected(this->_p);
|
||
}
|
||
int Sysilable()
|
||
{
|
||
return System_Net_Sockets_Socket_Available(this->_p);
|
||
}
|
||
bool Syocking()
|
||
{
|
||
return System_Net_Sockets_Socket_Blocking(this->_p);
|
||
}
|
||
void SetBlocking(bool v)
|
||
{
|
||
System_Net_Sockets_Socket_Blocking_Set(this->_p , v);
|
||
}
|
||
bool SyntFragment()
|
||
{
|
||
return System_Net_Sockets_Socket_DontFragment(this->_p);
|
||
}
|
||
void SetDontFragment(bool v)
|
||
{
|
||
return System_Net_Sockets_Socket_DontFragment_Set(this->_p , v);
|
||
}
|
||
bool DualMode()
|
||
{
|
||
return System_Net_Sockets_Socket_DualMode(this->_p);
|
||
}
|
||
void SetDualMode(bool v)
|
||
{
|
||
System_Net_Sockets_Socket_DualMode_Set(this->_p , v);
|
||
}
|
||
void SetEnableBroadcast(bool v)
|
||
{
|
||
System_Net_Sockets_Socket_EnableBroadcast_Set(this->_p , v);
|
||
}
|
||
void SetExclusiveAddressUse(bool v)
|
||
{
|
||
System_Net_Sockets_Socket_ExclusiveAddressUse_Set(this->_p , v);
|
||
}
|
||
Socket* Accept()
|
||
{
|
||
Socket* sk = new Socket();
|
||
sk->_p = System_Net_Sockets_Socket_Accept(this->_p);
|
||
return sk;
|
||
}
|
||
void Close()
|
||
{
|
||
System_Net_Sockets_Socket_Close(this->_p);
|
||
}
|
||
void Close(int timeout)
|
||
{
|
||
System_Net_Sockets_Socket_Close(this->_p , timeout);
|
||
}
|
||
void Connect(const char* host , int port)
|
||
{
|
||
System_Net_Sockets_Socket_Connect(this->_p , host , port);
|
||
}
|
||
void Disconnect(bool reuseSocket)
|
||
{
|
||
System_Net_Sockets_Socket_Disconnect(this->_p , reuseSocket);
|
||
}
|
||
void Listen()
|
||
{
|
||
System_Net_Sockets_Socket_Listen(this->_p);
|
||
}
|
||
void ListenI(int backlog)
|
||
{
|
||
System_Net_Sockets_Socket_ListenI(this->_p , backlog);
|
||
}
|
||
int Receive(byte* buffer , int len , SocketFlags flg)
|
||
{
|
||
return System_Net_Sockets_Socket_Receive(this->_p , buffer , len , flg);
|
||
}
|
||
int Send(byte* buffer , int len)
|
||
{
|
||
return System_Net_Sockets_Socket_Send(this->_p , buffer , len);
|
||
}
|
||
int SendTo(const char* ip , int port , byte* buffer , int len)
|
||
{
|
||
return System_Net_Sockets_Socket_SendTo(this->_p , ip , port , buffer , len);
|
||
}
|
||
void Bind(const char* ip , int port)
|
||
{
|
||
System_Net_Sockets_Socket_Bind(this->_p , ip , port);
|
||
}
|
||
};
|
||
}
|
||
}
|
||
namespace Threading
|
||
{
|
||
namespace Tasks
|
||
{
|
||
#define NEWRASK(x) async(launch::async , x );
|
||
template<typename T>
|
||
class Task;
|
||
|
||
template<typename R , typename...Args>
|
||
class Task<R(Args...)>
|
||
{
|
||
public:
|
||
std::future<R> syfun;
|
||
std::function<R(Args...)>&& Func = nullptr;
|
||
Task(std::function<R(Args...)>&& f)
|
||
{
|
||
this->Func = f;
|
||
}
|
||
void Start()
|
||
{
|
||
this->syfun = NEWRASK(this->Func);
|
||
}
|
||
R Wait()
|
||
{
|
||
this->syfun.wait();
|
||
return this->syfun.get();
|
||
}
|
||
|
||
};
|
||
}
|
||
}
|
||
} |