而且我也用TlbImp工具来转化成CLR函数库,还是不行啊: TlbImp error: The input file 'D:\Example\MyDesign\bin\Debug\SFR2.DLL' is not a v alid type library 急急急!!! 谢谢!!!
dll声明和调用的例子 // Declare a class member for each structure element. [ StructLayout( LayoutKind.Sequential )] public class SystemTime { public ushort year; … public ushort milliseconds; }public class LibWrap { // Declare a managed prototype for the unmanaged function. [ DllImport( "Kernel32.dll" )] public static extern void GetSystemTime( [In,Out] SystemTime st ); }
你看看.net自带的例子吧 Microsoft Visual Studio .NET\FrameworkSDK\Samples\Technologies\Interop\PlatformInvoke\WinAPIs
RegAsm 错误:“D:\Example\MyDesign\bin\Debug\SFR2.dll”不是有效的 .NET 程序集,
因此未能加载它
怎么办啊?
TlbImp error: The input file 'D:\Example\MyDesign\bin\Debug\SFR2.DLL' is not a v
alid type library
急急急!!!
谢谢!!!
// Declare a class member for each structure element.
[ StructLayout( LayoutKind.Sequential )]
public class SystemTime
{
public ushort year;
…
public ushort milliseconds;
}public class LibWrap
{
// Declare a managed prototype for the unmanaged function.
[ DllImport( "Kernel32.dll" )]
public static extern void GetSystemTime( [In,Out] SystemTime st );
}
Microsoft Visual Studio .NET\FrameworkSDK\Samples\Technologies\Interop\PlatformInvoke\WinAPIs
怎么办啊??
OPEN(5,FILE='INT.DAT',STATUS='OLD')
OPEN(6,FILE='OUT.LIS',STATUS='NEW') CALL INPUT
CALL STIFS
CALL LOADS
CALL LDLTS
CALL STRES
CLOSE(5)
CLOSE(6)
STOP
END
// Copyright
// Microsoft Corporation
// All rights reserved// FindFile.csusing System;
using System.Runtime.InteropServices;/*
typedef struct _WIN32_FIND_DATA
{
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[ MAX_PATH ];
TCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATA, *PWIN32_FIND_DATA;
*/[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )]
public class FindData
{
public int fileAttributes = 0;
// creationTime was embedded FILETIME structure
public int creationTime_lowDateTime = 0 ;
public int creationTime_highDateTime = 0;
// lastAccessTime was embedded FILETIME structure
public int lastAccessTime_lowDateTime = 0;
public int lastAccessTime_highDateTime = 0;
// lastWriteTime was embedded FILETIME structure
public int lastWriteTime_lowDateTime = 0;
public int lastWriteTime_highDateTime = 0;
public int nFileSizeHigh = 0;
public int nFileSizeLow = 0;
public int dwReserved0 = 0;
public int dwReserved1 = 0;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=256 )]
public String fileName = null;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=14 )]
public String alternateFileName = null;
}public class LibWrap
{
//HANDLE FindFirstFile(LPCTSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData);
[ DllImport( "Kernel32.dll", CharSet=CharSet.Auto )]
public static extern IntPtr FindFirstFile( String fileName, [ In, Out ] FindData findFileData );
}public class App
{
public static void Main()
{
FindData fd = new FindData();
IntPtr handle = LibWrap.FindFirstFile( "C:\\*.*", fd );
Console.WriteLine( "The first file: {0}", fd.fileName );
}
}
char[100] space;//space 的大小一定要大于或等于B占用的空间。将A编译成DLL,必须是VC环境,这个新DLL一定可以在C#中用的,呵呵,有时Game软件的外挂或修改器就是这么做的。
EXAMPLE:csc /out:要输出的文件的位置和文件名 /in(好象是的):要编译成DLL文件的位置和文件名。
然后再在Global的文件中修改在〈assemmlyes>〈/assemmlyes>中添加〈add assemmly〉dll的文件名〈/assemmly〉
在要使用的地方用using语句就好了;!!!
有些地方我记的也不太清楚,但过程就是这样的!!!!!!!!!!!!!