当前位置:首页 » 编程博文
开发技术指南» 文章正文
    引言: 在C#中采用的是事件驱动方式,但在我们使用的过程中,有时候通过调用系统原有的消息,处理起来会比较简单一些,特别是在处理与DLL文件的交互时,的确是非常的方便。
 

 

 ·用c#编写获取远程ip,mac的方法    »显示摘要«
    摘要:如果要想获得远程的地址,需要用sendarp这个函数来实现。具体的代码如下:[dllimport("iphlpapi.dll")]private static unsafe extern int sendarp(int32 dest,int32 host,ref intptr mac,ref intptr length);[dllimport("ws2_32.dll&......
 ·c#如何取硬件标志    »显示摘要«
    摘要:using system;using system.runtime.interopservices;using system.management;namespace hardware{/// <summary>/// hardware_mac 的摘要说明。/// </summary>public class hardwareinfo{ //取机器名 public stri......


在C#中使用热键隐含窗口

     在c#中采用的是事件驱动方式,但在我们使用的过程中,有时候通过调用系统原有的消息,处理起来会比较简单一些,特别是在处理与dll文件的交互时,的确是非常的方便.

   在c#中使用自定义消息 【程序编程相关:一个操作注册表的类

【推荐阅读:xmlhttp 抓取网页内容2

     在c#中使用自定义消息非常简单,只需要下面几个简单的步骤就可以了: 【扩展信息:从魔兽中的英雄设计机制来窥探面向对象的思

1.  定义消息

定义消息的方法与vc中定义消息有一点点不同

比如在vc中申明一个自定义消息:

#define wm_test wm_user + 101

而在c#中消息需要定义成windows系统中的原始的16进制数字,比如自定义消息

public const int user = 0x0400;

那么我们在vc中申明的自定义消息,在c#中就可以做对应的声明:

         public const int wm_test = user+101;

    

2.  发送消息

消息发送是通过windows提供的api函数sendmessage来实现的,它的原型定义:        [dllimport("user32.dll",entrypoint="sendmessage")]

          private static extern int sendmessage(

            intptr hwnd,      // handle to destination window

            uint msg,         // message

            uint wparam,      // first message parameter

            uint lparam       // second message parameter

       );

3.  消息接收

消息发出之后,在form中如何接收呢?我们可以重载defwinproc函数来接收消息.


...   下一页
 ·building a t-sql loop    »显示摘要«
    摘要:november 5, 2003t-sql programming part 2 - building a t-sql loopby gregory a. larsen this is the second article in my t-sql programming series. this article will discuss building a program loop usi......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE