这个怎样写成DLL?该怎么处理

这个怎样写成DLL?
本帖最后由 ilearn 于 2013-05-23 21:09:31 编辑
网上有许多DES算法的例子,但是我这个调用。NET类库的例子怎样把它变成win32 DLL供其它语言调用?这是MSDN的例子,环境不用和我考虑,因为我的环境已经全部部署好.NET了,谢谢,我不想把下面部署成COM+,只想把String^ Decrypt( array<Byte>^CypherText, SymmetricAlgorithm^ key )部署成WIN32 DLL ,请问怎样做?


// This sample demonstrates using a key based on the cryptographic service provider (CSP) version
// of the Data Encryption Standard (DES)algorithm to encrypt a string to a byte array, and then 
// to decrypt the byte array back to a string.
using namespace System;
using namespace System::IO;
using namespace System::Text;
using namespace System::Security::Cryptography;



// Decrypt the byte array.
String^ Decrypt( array<Byte>^CypherText, SymmetricAlgorithm^ key )
{

   // Create a memory stream to the passed buffer.
   MemoryStream^ ms = gcnew MemoryStream( CypherText );

   // Create a CryptoStream using the memory stream and the 
   // CSP DES key. 
   CryptoStream^ encStream = gcnew CryptoStream( ms,key->CreateDecryptor(),CryptoStreamMode::Read );

   // Create a StreamReader for reading the stream.
   StreamReader^ sr = gcnew StreamReader( encStream );

   // Read the stream as a string.
   String^ val = sr->ReadLine();

   // Close the streams.
   sr->Close();
   encStream->Close();
   ms->Close();
   return val;
}



------解决方案--------------------
新建一个MFCDLL,开启CLR,在里面导出你需要的东西。
备注:内部实现的方式外面调用者跟本就不会去管。

建议搜索关键字:托管C++

------解决方案--------------------
托管c++ 编译出来的dll 需要 .net 框架 支持 
如果需要编译为原生dll 需要把托管c++的源码进行修改为 原生c++ 源码 然后 创建一个 win32 dll 进行编译