Ice Core Code

zhaozj2021-02-16  75

using System; using System.Diagnostics; using System.IO; using System.Windows.Forms; using System.Threading; using System.Runtime.InteropServices; using System.Drawing; using System.Drawing.Imaging;

Namespace RemoteClass {///

/// Remote monitoring operation ////

Public Class RemoteClass: System.MarshalByrefObject {Public RemoteClass () {} #Region Get, Delete, Run Process // ///> Get the current process name //////

Array of process names

Public String [] getProcessName () {// Gets the unit of this component so the process array process [] myprocesses = process.getProcesses ("."); string [] processnames = new string [myprocesses.length]; for (int) i = 0; i

{

ProcessNames [i] = myprocesses [i] .processname;

}

Return ProcessNames;

}

// / / / End the specified process // // / / The name of the process to end ////

Whether the operation is successful

Public int endprocess (String ProcessName)

{

/ / Get the process of the specified name in this unit

Process [] myprocess = process.getProcessesbyName (ProcessName, ".");

MyProcess [0] .closemainwindow ();

MyProcess [0] .kill ();

Return 1;

}

// / / / //// /////// // // //////bit of the program PUBLIC VOID EXEPROCESS (STRING PATH)

{

PROCESS process1 = new process ();

Process1.startinfo.filename = path;

PROCESS1.START ();

}

#ndregion

#Region Send Message

/ / / / / Display message // // / / message to display

Public void showmessage (string message)

{

THIS.MESSAGE = Message;

// Multithreaded display message

Thread T = New Thread (New ThreadStart (M));

T.Start ();

} Private string message; private void m () {MessageBox.show (Message, "letter", messageboxbuttons.okcancel);} #ENDREGION

#Region get file or dir's info ///

/// Get the list of file information of the specified folder ///

/// Specified folder path ///

File information list

Public fileInfo [] getfileinfo (string path) {DirectoryInfo D = New DirectoryInfo (PATH); RETURN D.GETFILES ();} /// // Get the subfolder list of the specified folder //// / / specified Folder path ////

Folder information list

Public DirectoryInfo [] getdir (string path) {DirectoryInfo D = new DirectoryInfo (path); return d.Getdirectories ();} # endregion # region delete file or dir ///////

// / Delete the specified file ///

// / The file path to be deleted public void Delfile (String Path) {file.delete (path);}

///

/// Delete the specified folder, contain all the files and all of them ///

/// The path to the folder to be deleted public void deldir (string path) {Directory.delete (path, true);} #ENDREGION

#Region KeyBroad Event [DLLIMPORT ("User32.dll")] public static extern void keybd_event (int D, byte i, system.int32 q, system.intptr s); // analog keyboard event /////

/// Simulate Press a button ///

/// The key value of the button to be imitated public void keydown (int keyValue) {keybd_event (keyvalue, 0, 0, (intptr) 0);} // /// Simulation release a button / / / / / / / / / / / / / / / / / The key value of the button Public void keypress (int keyvalue) {keybd_event (keyvalue, 0, 2, (intptr) 0);} // // /} A complete button process / / / / / / / / / / / / / / / / 要Key value of the button Public void key (int keyvalue) {keybd_event (keyvalue, 0, 0, (intptr) 0); keybd_event (keyvalue, 0, 2, (intptr) 0);} // // / Simulate a complete Button Procedure /// /// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 0, 2, ptr);} #ENDREGION

#region cut screen [System.Runtime.InteropServices.DllImportAttribute ( "gdi32.dll")] private static extern bool BitBlt (IntPtr hdcDest, // target DC handle int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, // Source DC handle INT NXSRC, INT NYSRC, System.Int32 DWROP / / Raster processing value); ///

/// Screenshot ///

///

Public stream getImage () {// Get a form that maximizes does not have a title bar, in order to intercept the entire screen Form f = new form (); formborderstyle = system.windows.forms.formorderstyle.none; f.WindowState = system .Windows.forms.formwindowState.maximized; // Get the size Rect = new rectangle (); Rect = Screen.getBounds (f); // Create an image of the current screen to the template graphics g1 = f. CreateGraphics (); // Create a bitmap image method with a screen size = new bitmap (Rect.width, Rect.Height, G1); graphics g2 = graphics.fromimage (MyImage); // Get the screen DC INTPTR DC1 = g1.GethDC (); // Get bitmap DC INTPTR DC2 = G2.GETHDC (); // Call this API function, implement the screen capture Bitblt (DC2, 0, 0, Rect.Width, Rect.Height, DC1, 0, 0, 13369376); // Release the DC G1.ReleaseHDC (DC1) of the screen; // Release the DC G2.ReleaseHDC (DC2) of Bitmap; f.dispose (); stream s = new system.io.MemoryStream (); // Save MyImage.Save (S, Imageformat.jpeg) in JPG file format; rates.dispose (); return s;} # endregion # region lock mouse [structLayout (layoutkind.explicit)] public struct rest { [Field Offset (0)] public int [; [Fieldoffset (4)] public int top; [Fieldoffset (8)] public int right; [Fieldoffset (12)] public int bottom;} [DLLIMPORT ("user32.dll")] Public Static Extern Void Clipcursor (Ref Rect Rect); ///

/// Lock the mouse over a specific rectangular area ///

/////////////////////////////////////////////////////////////////////////////////////////////////////// RECT R; R.BOTTOM = BUTTOM; R.LEFT = LEFT; R. TOP = top; r.right = right; clipcursor (ref r);} #ENDREGION

#REGON MOUSE CLICK / / Mouse Click on the Mouse Simulation Method in the Mouse_Event API [DLLIMPORT ("User32.dll")] Public Static Extern Void Mouse_Event (int dwflags, int dx, int dy, uint dwdata, ulong dwextrainfo) ; private const int MOUSEEVENTF_LEFTDOWN = 2; private const int MOUSEEVENTF_LEFTUP = 4; private const int MOUSEEVENTF_RIGHTDOWN = 8; private const int MOUSEEVENTF_RIGHTUP = 16; [DllImport ( "User32.dll")] public static extern bool SetCursorPos (int x, int y ); // Position the position of the mouse ///

/// Simulate the left mouse button click ///

/// x relative screen relative position /// Y's relative screen relative position PUBLIC VOID MOUSE_CLICK (FLOAT Y) {// calculate absolute position for the screen int Screenx = (int) (x * screen .PrimaryScreen.Bounds.Width); int screenY = (int) (y * Screen.PrimaryScreen.Bounds.Height); // position the mouse events on the screen position SetCursorPos (screenX, screenY); mouse_event (MOUSEEVENTF_LEFTDOWN, screenX, screenY , 0, 0); mouse_event (mouseEventf_leftup, screenx, screeny, 0, 0);} // // // ////// x relative screen of the relative position /// y The relative position of the screen public void mouse_doubleclick (float x, float y) {int Screenx = (int) (x * screen.primaryScreen.bounds.width); int screeny = (int) (Y * screen.primaryScreen.bounds.Height) ; SetCursorPos (screenX, screenY); mouse_event (MOUSEEVENTF_LEFTDOWN, screenX, screenY, 0,0); mouse_event (MOUSEEVENTF_LEFTUP, screenX, screenY, 0,0); mouse_event (MOUSEEVENTF_LEFTDOWN, screenX, screenY, 0,0); mouse_event (MOUSEEVENTF_LEFTUP , Screenx, Screeny, 0, 0);} ///// Simulation mouse right click on ///// x relative position /// y's relative position PUBLIC VOID MOUSE_RIGHTCLICK (Float X, float y) {int Screenx = (int) (x * sc reen.PrimaryScreen.Bounds.Width); int screenY = (int) (y * Screen.PrimaryScreen.Bounds.Height); SetCursorPos (screenX, screenY); mouse_event (MOUSEEVENTF_RIGHTDOWN, screenX, screenY, 0,0); mouse_event (MOUSEEVENTF_RIGHTUP , screenX, screenY, 0,0);} # endregion # region cdrom event [DllImport ( "winmm.dll")] public static extern long mciSendStringA (string lpstrCommand, string lpstrReturnString, long uReturnLength, long hwndCallback); // lpstrCommand this Is the control command parameter // lpstrreturnstring This is the return value // ureturnLength Return value length parameter //////

/// Open the optical drive ///

Public void opencdrom () {mcIndstringa ("SET CDAUDIO DOOR OPEN", "", 0, 0);} ///

/// Turn off the optical drive ///

Public void closecdrom ()

{

McIndstringa ("SET CDAUDIO DOOR CLOSED", "", 0, 0);}

#ndregion}}}

转载请注明原文地址:https://www.9cbs.com/read-13807.html

New Post(0)