C Shape如何制作..自己程序才能打开的文件...举个例子,...说说原理...

解决方案 »

  1.   

    System.Diagnostics.Process.Start(FilePath);
      

  2.   

    使用AES加密文件,自己在程序里解密,关于AES算法可以到相关官方网站找到,自己进行适量修改即可.
    如果要求不高可以考虑使用3DES
      

  3.   

    修改注册表 
    hkey_Classes_Root 
    下面新建一个.tlh的项 
    然后新建一个default的 value=tlh的键值 然后再现键一个tlh的项 
    然后在下面新建一个shell的项 
    然后在下面再新建一个open的项 
    然后在下面再新建一个command的项目 
    然后在下面新建一个defalut的键值 value=""\Program Files\TBS\PatchClient\你的应用程序.exe"" ""%%1""  
    这样你在运行点.tlh文件的时候会把路径传给应用程序.exe 
    从b.exe的 main(string[] args)里面取得 然后给你清洁工的代码........其实就你在程序打包的时候写进去就可以了 using Microsoft.Win32; 
    using System.Runtime.InteropServices; [DllImport("shell32.dll")] 
    private static extern void SHChangeNotify(uint wEventId, uint uFlags, 
        IntPtr dwItem1, IntPtr dwItem2); 
    private const uint SHCNE_ASSOCCHANGED = 0x08000000; 
    private const uint SHCNF_IDLIST = 0x0000; 
    private const uint SHCNF_FLUSH = 0x1000; private bool registryShell = false; // 是否关联文件 private void RegistryShell() 

        registryShell = true; 
        RegistryKey vRegistryKey = Registry.ClassesRoot.CreateSubKey(".xxx"); 
        vRegistryKey.SetValue("", "xxx Document"); 
        vRegistryKey = Registry.ClassesRoot.CreateSubKey( 
            @"xxx Document\shell\open\command", 
            RegistryKeyPermissionCheck.ReadWriteSubTree); 
        vRegistryKey.SetValue("", Application.ExecutablePath + " \"%1\""); 
        vRegistryKey = Registry.ClassesRoot.CreateSubKey( 
            @"xxx Document\DefaultIcon", 
            RegistryKeyPermissionCheck.ReadWriteSubTree); 
        vRegistryKey.SetValue("", Application.ExecutablePath + ",0");     SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST ¦ SHCNF_FLUSH, 
            IntPtr.Zero, IntPtr.Zero); 
    } private void UnregistryShell() 

        registryShell = false; 
        bool changeRegistry = false; 
        RegistryKey vRegistryKey = Registry.ClassesRoot.OpenSubKey(".xxx"); 
        if (vRegistryKey != null) 
        { 
            changeRegistry = true; 
            vRegistryKey.Close(); 
            Registry.ClassesRoot.DeleteSubKeyTree(".xxx"); 
        }     vRegistryKey = Registry.ClassesRoot.OpenSubKey("xxx Document"); 
        if (vRegistryKey != null) 
        { 
            changeRegistry = true; 
            vRegistryKey.Close(); 
            Registry.ClassesRoot.DeleteSubKeyTree("xxx Document"); 
        } 
        if (changeRegistry) 
            SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST ¦ SHCNF_FLUSH, 
                IntPtr.Zero, IntPtr.Zero); 
    } private bool IsRegistryShell() 

        RegistryKey vRegistryKey = Registry.ClassesRoot.OpenSubKey(".xxx"); 
        if (vRegistryKey == null) return false; 
        vRegistryKey = Registry.ClassesRoot.OpenSubKey( 
            @"xxx Document\shell\open\command"); 
        if (vRegistryKey == null) return false; 
        if (vRegistryKey.GetValue("").ToString().ToLower() != 
            Application.ExecutablePath.ToLower() + " \"%1\"") return false; 
        return true; 

    // 处理程序参数 
    private void Form1_Load(object sender, EventArgs e) 

        string[] vCommands = Environment.GetCommandLineArgs(); 
        if (vCommands.Length > 1) 
        { 
            OpenDocument(vCommands[1]); 
        } 

    http://topic.csdn.net/u/20080521/23/32f7d344-b115-4a53-88fe-65530b685c27.html
      

  4.   

    .net不是有自带的md5算法吗?
    在代码中自己定义一个密码(比如"abcd"),然后
    string s = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("abcd", "MD5");存文件的时候把算出的加密字符换成bit,重复的跟文件的每个bit异或一次.
    读的时候也是用样的方法每个bit都取异或一次.
      

  5.   


    我还没试过异或...就写个超级简单的例子把 public string UserMd5(string content)
    {
    string result="";
    MD5 md5 = MD5.Create
    byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(content));

    for (int i = 0; i < s.Length; i++)
    {
    result = result + s[i].ToString("X");
    }
    return result;
    }以上是个MD5的简单函数...那试写一个你说的异或..我看看是怎么搞的...我不太会...