Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C#µ÷ÓÃC DLL

ÔÚºÏ×÷¿ª·¢Ê±£¬C#ʱ³£ÐèÒªµ÷ÓÃC++DLL£¬µ±´«µÝ²ÎÊýʱʱ³£Óöµ½ÎÊÌ⣬ÓÈÆäÊÇ´«µÝºÍ·µ»Ø×Ö·û´®ÊÇ£¬ÏÖ×ܽáһϣ¬·ÖÏí¸ø´ó¼Ò£º
VC++ÖÐÖ÷Òª×Ö·û´®ÀàÐÍΪ£ºLPSTR,LPCSTR, LPCTSTR, string, CString, LPCWSTR, LPWSTRµÈ
µ«×ªÎªC#ÀàÐÍÈ´²»ÍêÈ«Ïàͬ¡£
Ö÷ÒªÓÐÈçϼ¸ÖÖת»»£º
½«stringתΪIntPtr£ºIntPtr System.Runtime.InteropServices.Marshal.StringToCoTaskMemAuto(string)
½«IntPtrתΪstring£ºstring System.Runtime.InteropServices.MarshalPtrToStringAuto(IntPtr)
ÀàÐͶÔÕÕ£º
BSTR ---------  StringBuilder
LPCTSTR --------- StringBuilder
LPCWSTR ---------  IntPtr
handle---------IntPtr
hwnd-----------IntPtr
char *----------string
int * -----------ref int
int &-----------ref int
void *----------IntPtr
unsigned char *-----ref byte
StructÐèÒªÔÚC#ÀïÖØж¨ÒåÒ»¸öStruct
CallBack»Øµ÷º¯ÊýÐèÒª·â×°ÔÚÒ»¸öίÍÐÀdelegate static extern int FunCallBack(string str);
×¢ÒâÔÚÿ¸öº¯ÊýµÄÇ°Ãæ¼ÓÉÏpublic static extern +·µ»ØµÄÊý¾ÝÀàÐÍ,Èç¹û²»¼Ópublic ,º¯ÊýĬÈÏΪ˽Óк¯Êý£¬µ÷Óþͻá³ö´í¡£
ÔÚC#µ÷ÓÃC++ DLL·â×°¿âʱ»á³öÏÖÁ½¸öÎÊÌ⣺
1£® Êý¾ÝÀàÐÍת»»ÎÊÌâ
2£® Ö¸Õë»òµØÖ·²ÎÊý´«ËÍÎÊÌâ
    Ê×ÏÈÊÇÊý¾ÝÀàÐÍת»»ÎÊÌâ¡£ÒòΪC#ÊÇ.NETÓïÑÔ£¬ÀûÓõÄÊÇ.NETµÄ»ù±¾Êý¾ÝÀàÐÍ£¬ËùÒÔʵ¼ÊÉÏÊǽ«C++µÄÊý¾ÝÀàÐÍÓë.NETµÄ»ù±¾Êý¾ÝÀàÐͽøÐжÔÓ¦¡£
    ÀýÈçC++µÄÔ­Óк¯ÊýÊÇ£º
int __stdcall FunctionName(unsigned char param1, unsigned short param2)
    ÆäÖеIJÎÊýÊý¾ÝÀàÐÍÔÚC#ÖУ¬±ØÐëתΪ¶ÔÓ¦µÄÊý¾ÝÀàÐÍ¡£È磺
[DllImport(“ COM DLL path/file ”)]
extern static int FunctionName(byte param1, ushort param2)
    ÒòΪµ÷ÓõÄÊÇ__stdcallº¯Êý£¬ËùÒÔʹÓÃÁËP/InvokeµÄµ÷Ó÷½·¨¡£ÆäÖеķ½·¨FunctionName±ØÐëÉùÃ÷Ϊ¾²Ì¬Íⲿº¯Êý£¬¼´¼ÓÉÏextern staticÉùÃ÷Í·¡£ÎÒÃÇ¿ÉÒÔ¿´µ½£¬ÔÚµ÷ÓõĹý³ÌÖУ¬unsigned char±äΪÁËbyte£¬unsigned short±äΪÁËushort¡£±ä»»ºó£¬²ÎÊýµÄÊý¾ÝÀàÐͲ»±ä£¬Ö»ÊÇÉùÃ÷·½Ê½±ØÐë¸ÄΪ.NETÓïÑԵĹ淶¡£
    ÎÒÃÇ¿ÉÒÔͨ¹ýϱíÀ´½øÐÐÕâÖÖת»»£º
Win32 Types
CLR Type
char, INT8, SBYTE, CHAR
System.SByte
short, short int, INT16, SHORT
System.Int16
int, long, long int, I


Ïà¹ØÎĵµ£º

MISRA ×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶

MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶(ǶÈëʽc¿ª·¢Õ߱ضÁ)
 
MISRA--×÷Ϊ¹¤Òµ±ê×¼µÄC±à³Ì¹æ·¶
 
  MISRA (The Motor Industry Software Reliability Association
Æû³µ¹¤ÒµÈí¼þ¿É¿¿ÐÔÁª»á)
ÊÇλÓÚÓ¢¹úµÄÒ»¸ö¿ç¹úÆû³µ¹¤ÒµÐ­»á£¬Æä³ÉÔ±°üÀ¨Á˴󲿷ÖÅ·ÃÀÆû³µÉú²úÉÌ¡£ÆäºËÐÄʹÃüÊÇΪÆû³µ¹¤ÒµÌṩ·þÎñºÍЭÖú£¬°ïÖ ......

C/S½á¹¹Web»¯£¬ÆƳýERP·Ö²¼Ä£Ê½Æ¿¾±

2009Ä꣬¾­¼ÃΣ»úÁýÕÖϵÄÖйú¹ÜÀíÈí¼þÐÐÒµ£¬ÓëÍùÄêÏà±È¾²Ä¬ÁËÐí¶à¡£²»¾ÃÇ°£¬SAPÖйúÑо¿Ôº×ܲÃÜÇÏé÷ëÅúÆÀ¹ú²úÈí¼þ¼¼Êõ»¹Í£ÁôÔÚ10ÄêÇ°¿Í»§¶Ë(Clien/Server)¼Ü¹¹Ë®Æ½£¬Òý·¢Òµ½çÒ»³¡´óÂÛÕ½¡£ÄÇôÖйú¹ÜÀíÈí¼þ¼¼ÊõÊÇ·ñÕæµÄÒѾ­Âäºó?
¡¡¡¡C/SÓ¦ÓÃÈÔÓÐÓÅÊÆ
¡¡¡¡ÄÇôÖйú¹ÜÀíÈí¼þ¼¼ÊõÊÇ·ñÒѾ­Âäºó?
¡¡¡¡C/S½á¹¹³ÌÐòÓëB/S(Web) ......

C/C++ qsort()¿ìËÙÅÅÐòµÄÓ÷¨


CÓïÑÔÖÐÅÅÐòµÄËã·¨ÓкܶàÖÖ£¬ÏµÍ³Ò²ÌṩÁËÒ»¸öº¯Êýqsort()¿ÉÒÔʵÏÖ¿ìËÙÅÅÐò¡£Ô­ÐÍÈçÏ£º
void qsort(void *base, size_t nmem, size_t size, int (*comp)(const void *, const void *));
Ëü
¸ù¾ÝcompËùÖ¸ÏòµÄº¯ÊýËùÌṩµÄ˳Ðò¶ÔbaseËùÖ¸ÏòµÄÊý×é½øÐÐÅÅÐò£¬nmemΪ²Î¼ÓÅÅÐòµÄÔªËظöÊý£¬sizeΪÿ¸öÔªËØËùÕ¼µÄ×Ö½ÚÊý¡£Àý È ......

c#Öе÷ÓÃJavaScript½Å±¾º¯ÊýµÄÒ»ÖÖ·½·¨

ÀûÓà           Page.RegisterStartupScript("", "<script language='javascript'> results();</script>");    
      »òÕßÊÇ         Page.RegisterClient ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ