Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Kilka błędów przy próbie kompilacji


Rekomendowane odpowiedzi

Opublikowano

Witam podczas próby kompilacji otrzymuje 5 błędów i nie wiem jak się ich pozbyć.

 

Błędy:

 

 

Błąd 3 W elemencie „Program.inne.EmptyWorkingSet(System.IntPtr)” musi być zadeklarowana treść, ponieważ nie jest on oznaczony przy użyciu słowa kluczowego „abstract”, „extern” lub „partial” Wiersz: 20 Kolumna: 28

Błąd 5 W elemencie „IniFile.GetPrivateProfileString(int, string, string, byte[], int, string)” musi być zadeklarowana treść, ponieważ nie jest on oznaczony przy użyciu słowa kluczowego „abstract”, „extern” lub „partial”Wiersz: 25 Kolumna: 24

Błąd 4 W elemencie „IniFile.GetPrivateProfileString(string, string, string, System.Text.StringBuilder, int, string)” musi być zadeklarowana treść, ponieważ nie jest on oznaczony przy użyciu słowa kluczowego „abstract”, „extern” lub „partial”Wiersz: 22 Kolumna: 24

Błąd 2 W elemencie „IniFile.WritePrivateProfileString(string, string, string, string)” musi być zadeklarowana treść, ponieważ nie jest on oznaczony przy użyciu słowa kluczowego „abstract”, „extern” lub „partial”Wiersz: 19 Kolumna: 25

Błąd 1 W elemencie „IniFile.WritePrivateProfileStruct(string, string, string, int, string)” musi być zadeklarowana treść, ponieważ nie jest on oznaczony przy użyciu słowa kluczowego „abstract”, „extern” lub „partial”Wiersz: 16 Kolumna: 24

 

IniFile:

 

 

using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

public class IniFile
{
    public string path;

    public IniFile(string INIPath)
    {
        this.path = Path.GetDirectoryName(Application.ExecutablePath) + "/" + INIPath;
    }

    [DllImport("kernel32")]
    private static int WritePrivateProfileStruct(string pSection, string pKey, string pValue, int pValueLen, string pFile);

    [DllImport("kernel32")]
    private static long WritePrivateProfileString(string section, string key, string val, string filePath);

    [DllImport("kernel32")]
    private static int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

    [DllImport("kernel32")]
    private static int GetPrivateProfileString(int Section, string Key, string Value, [MarshalAs(UnmanagedType.LPArray)] byte[] Result, int Size, string FileName);

    public void IniWriteValue(string Section, string Key, string Value)
    {
        IniFile.WritePrivateProfileString(Section, Key, Value, this.path);
    }

    public string IniReadValue(string Section, string Key, string DefaultValue = "")
    {
        StringBuilder retVal = new StringBuilder(10240);
        IniFile.GetPrivateProfileString(Section, Key, "", retVal, 10240, this.path);
        if (((object)retVal).ToString().Length > 0)
            return ((object)retVal).ToString();
        else
            return DefaultValue;
    }

    public string[] GetSectionNames()
    {
        int Size = 500;
        byte[] numArray;
        int privateProfileString;
        while (true)
        {
            numArray = new byte[Size];
            privateProfileString = IniFile.GetPrivateProfileString(0, "", "", numArray, Size, this.path);
            if (privateProfileString >= Size - 2)
                Size *= 2;
            else
                break;
        }
        return Encoding.ASCII.GetString(numArray, 0, privateProfileString - (privateProfileString > 0 ? 1 : 0)).Split(new char[1]);
    }

    public void RemoveSection(string pSection)
    {
        IniFile.WritePrivateProfileString(pSection, (string)null, (string)null, this.path);
    }
}

 

inne:

 

 

using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;

namespace Program
{
    public class inne
    {
        private static byte[] _salt = Encoding.ASCII.GetBytes("o6806642kbM7c5");

        static inne()
        {
        }

        [DllImport("psapi.dll")]
        private static int EmptyWorkingSet(IntPtr hwProc);

        public static void MinimizeFootprint()
        {
            inne.EmptyWorkingSet(Process.GetCurrentProcess().Handle);
        }

        public string[] StringBeetwen(string Data, string start, string end)
        {
            int index = 0;
            MatchCollection matchCollection = Regex.Matches(Data, Regex.Escape(start) + "(.*?)" + Regex.Escape(end));
            string[] strArray = new string[matchCollection.Count];
            foreach (Match match in matchCollection)
            {
                strArray[index] = match.Groups[1].Value;
                ++index;
            }
            return strArray;
        }

        public static string EncryptStringAES(string plainText, string sharedSecret)
        {
            if (string.IsNullOrEmpty(plainText))
                return "";
            if (string.IsNullOrEmpty(sharedSecret))
                throw new ArgumentNullException("sharedSecret");
            RijndaelManaged rijndaelManaged = (RijndaelManaged)null;
            try
            {
                Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(sharedSecret, inne._salt);
                rijndaelManaged = new RijndaelManaged();
                rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8);
                ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV);
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    memoryStream.Write(BitConverter.GetBytes(rijndaelManaged.IV.Length), 0, 4);
                    memoryStream.Write(rijndaelManaged.IV, 0, rijndaelManaged.IV.Length);
                    using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, encryptor, CryptoStreamMode.Write))
                    {
                        using (StreamWriter streamWriter = new StreamWriter((Stream)cryptoStream))
                            streamWriter.Write(plainText);
                    }
                    return Convert.ToBase64String(memoryStream.ToArray());
                }
            }
            finally
            {
                if (rijndaelManaged != null)
                    rijndaelManaged.Clear();
            }
        }

        public static string DecryptStringAES(string cipherText, string sharedSecret)
        {
            if (string.IsNullOrEmpty(cipherText))
                return "";
            if (string.IsNullOrEmpty(sharedSecret))
                throw new ArgumentNullException("sharedSecret");
            RijndaelManaged rijndaelManaged = (RijndaelManaged)null;
            try
            {
                Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(sharedSecret, inne._salt);
                using (MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(cipherText)))
                {
                    rijndaelManaged = new RijndaelManaged();
                    rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8);
                    rijndaelManaged.IV = inne.ReadByteArray((Stream)memoryStream);
                    ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV);
                    using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Read))
                    {
                        using (StreamReader streamReader = new StreamReader((Stream)cryptoStream))
                            return streamReader.ReadToEnd();
                    }
                }
            }
            finally
            {
                if (rijndaelManaged != null)
                    rijndaelManaged.Clear();
            }
        }

        private static byte[] ReadByteArray(Stream s)
        {
            byte[] buffer1 = new byte[4];
            if (s.Read(buffer1, 0, buffer1.Length) != buffer1.Length)
                throw new SystemException("Stream did not contain properly formatted byte array");
            byte[] buffer2 = new byte[BitConverter.ToInt32(buffer1, 0)];
            if (s.Read(buffer2, 0, buffer2.Length) != buffer2.Length)
                throw new SystemException("Did not read byte array properly");
            else
                return buffer2;
        }
    }
}

 

Liczę na waszą pomoc i z góry dziękuję :)

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...