在我的blog上更新了几个link
看到Simple stack code这样的一篇文章,看到后真的是兴奋的难以自已。这是我目前从Whidbey 上看到的最另人激动的改进了。
在C++下编译的DLL可以在framework下直接#using了,不需要再使用Managed C++首先编译成framework版本的....
虽然不知道这个是怎么实现的,但是这个功能真的是有用呀。
还有一篇文章非常重要,
Is there any way to find out if a given DLL is managed or unmanaged without trying to load it?
// mcppfaq_isManaged.cpp
// compile with: /clr
// arguments: mcppfaq_delnative.dll
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
static bool isManaged(String __gc* sFilename)
{
try
{
Byte Data __gc[] = new Byte __gc[4096];
FileInfo __gc* file = new FileInfo(sFilename);
Stream __gc* fin = file -> Open(FileMode::Open, FileAccess::Read);
Int32 iRead = fin -> Read(Data, 0, 4096);
fin -> Close();
// Verify this is a executable/dll
if ((Data[1] << 8 | Data[0]) != 0x5a4d)
return false;
// This will get the address for the WinNT header
Int32 iWinNTHdr = Data[63]<<24 | Data[62]<<16 | Data[61] << 8 | Data[60];
// Verify this is an NT address
if ((Data[iWinNTHdr+3] << 24 | Data[iWinNTHdr+2] << 16
| Data[iWinNTHdr+1] << 8
| Data[iWinNTHdr]) != 0x00004550)
return false;
Int32 iLightningAddr = iWinNTHdr + 24 + 208;
Int32 iSum=0;
Int32 iTop = iLightningAddr + 8;
for (int i = iLightningAddr; i < iTop; i++)
iSum|=Data[i];
if (iSum == 0)
return false;
else
return true;
}
catch(Exception __gc* e)
{
throw
;
}
}
int main(int argc, char * argv[])
{
System::Console::WriteLine(isManaged(argv[1]));
}打印 | 张贴于 2003-11-14 15:12:00 | Tag:暂无标签
留言反馈
在VS.net 上要麻烦很多的。或许在MC++中相对还容易一些,但是对于VB.net 和Csharp 就麻烦多了
我曾经为此郁闷很久。。
只不过方法有些不同而已