使用C#调用windows API入门
|
Win32 Types
|
Specification
|
CLR Type
|
|
char, INT8, SBYTE, CHARâ€
|
8-bit signed integer
|
System.SByte
|
|
short, short int, INT16, SHORT
|
16-bit signed integer
|
System.Int16
|
|
int, long, long int, INT32, LONG32, BOOL†, INT
|
32-bit signed integer
|
System.Int32
|
|
__int64, INT64, LONGLONG
|
64-bit signed integer
|
System.Int64
|
|
unsigned char, UINT8, UCHAR†, BYTE
|
8-bit unsigned integer
|
System.Byte
|
|
unsigned short, UINT16, USHORT, WORD, ATOM, WCHAR†, __wchar_t
|
16-bit unsigned integer
|
System.UInt16
|
|
unsigned, unsigned int, UINT32, ULONG32, DWORD32, ULONG, DWORD, UINT
|
32-bit unsigned integer
|
System.UInt32
|
|
unsigned __int64, UINT64, DWORDLONG, ULONGLONG
|
64-bit unsigned integer
|
System.UInt64
|
|
float, FLOAT
|
Single-precision floating point
|
System.Single
|
|
double, long double, DOUBLE
|
Double-precision floating point
|
System.Double
|
|
†In Win32 this type is an integer with a specially assigned meaning; in contrast, the CLR provides a specific type devoted to this meaning.
|
||
using System;
using System.Runtime.InteropServices;
public class MSSQL_ServerHandler
{
[DllImport("kernel32.dll")]
public static extern int GetShortPathName
(
string path,
StringBuilder shortPath,
int shortPathLength
)
}
using System;
using System.Runtime.InteropServices;
public class MSSQL_ServerHandler
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength
)
}
[DllImport("kernel32.dll", EntryPoint="getShort")]
[DllImport] 虽等效于 [DllImportAttribute],但 DllImportAttribute 才是该属性在 .NET Framework 中的实际名称。本文出自 “锉人Kris” 博客,请务必保留此出处http://chris.blog.51cto.com/112473/29285
使用C#调用windows API入门的更多相关文章
- C#调用windows API的一些方法
使用C#调用windows API(从其它地方总结来的,以备查询) C#调用windows API也可以叫做C#如何直接调用非托管代码,通常有2种方法: 1. 直接调用从 DLL 导出的函数. 2. ...
- C#调用Windows API函数截图
界面如下: 下面放了一个PictureBox 首先是声明函数: //这里是调用 Windows API函数来进行截图 //首先导入库文件 [System.Runtime.InteropServices ...
- 【转】用C#调用Windows API向指定窗口发送
一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空间:using System.Runtime.InteropServices; 2.引用需要使用的方法,格式 ...
- C#中调用Windows API的要点 .
介绍 API(Application Programming Interface),我想大家不会陌生,它是我们Windows编程的常客,虽然基于.Net平台的C#有了强大的类库,但是,我们还是不能否认 ...
- c# 判断窗体是否永在最前(TopMost),调用windows API
许多程序都可以把自身的窗体设为最前显示状态,这个可以参考博客c#让窗体永在最前 调用windows api 将窗体设为topmost.那么如何判断桌面上的一个窗体是否为最前显示状态呢,不光是自己的程序 ...
- c#让窗体永在最前 调用windows api 将窗体设为topmost
有时候应用程序需要将一个窗体始终位于屏幕的最前面,即使切换到其它窗体也能看到该窗体,这样的窗体就叫做TopMost窗体. 用C#制作TopMost窗体之前,首先要了解如何声明SetWindowPos函 ...
- 善于 调用Windows API
前一段时间看见别人做的一个自动填写信息并且点击登录的程序,觉得很有意思. 其实就是在程序中调用Windows的API,那么如何调用,下面就做个简单的介绍. 写的简单粗暴, 不喜轻喷. 0.首先引入名称 ...
- C#中调用Windows API时的数据类型对应关系
原文 C#中调用Windows API时的数据类型对应关系 BOOL=System.Int32 BOOLEAN=System.Int32 BYTE=System.UInt16 CHAR=System. ...
- 用C#调用Windows API向指定窗口发送按键消息 z
用C#调用Windows API向指定窗口发送 一.调用Windows API. C#下调用Windows API方法如下: 1.引入命名空间:using System.Runtime.Interop ...
随机推荐
- android学习笔记30——AndroidMainfest.xml
Manifest.xml文件的职责:指定APP的包名.声明四大组件, 以及启动方式.指定APP运行的进程名称.指定APP权限.指定最小API版本.指定需要连接的库. Manifest.xml的格式:& ...
- Expecting "jsp:param" standard action with "name" and "value" attributes错误
错误信息如下: Servlet.service() for servlet [jsp] in context with path [/20161017] threw exception [/tag/s ...
- 关于mysql数据库在输入密码后,滴的一声直接退出界面的解决办法
转自:http://www.2cto.com/database/201412/361751.html 网上搜索到的解决办法: 1.找到mysql安装目录下的bin目录路径.2.打开cmd,进入到bin ...
- gcc中动态库和静态库的链接顺序
so文件:动态库a文件: 静态库exe文件:可执行程序(linux下以文件属性来标示是否是可执行文件,与后缀名无关) 经过自己写的一些测试程序,大致了解了下gcc中链接顺序问题,总结出以下几点:1,动 ...
- Linux大文件传输(转)
我们经常需要在机器之间传输文件.比如备份,复制数据等等.这个是很常见,也是很简单的.用scp或者rsync就能很好的完成任务.但是如果文件很大,需要占用一些传输时间的时候,怎样又快又好地完成任务就很重 ...
- Unix commands in Mac OS X
参考:http://www.renfei.org/blog/mac-os-x-terminal-101.html One command line includes 4 parts: Command ...
- bug_ _ 常见的bug1
===== 3 java.lang.reflect.InvocationTargetException 异常解决方法 在做djunit测试的时候,发生下面异常: java.lang.reflec ...
- MySQL 绿色版安装方法图文教程
一.下载,这里使用绿色解压缩版 http://mirror.services.wisc.edu/mysql/Downloads/MySQL-5.1/mysql-noinstall-5.1.32-win ...
- linux 好玩的命令
发现一个linux好玩的命令,随机显示名言警句和诗词:fortune 和 fortune-zh (中文) cowsay: 小动物说话- ________________________________ ...
- windows service自动启动相关设置
http://blog.csdn.net/thebesttome/article/details/7590025 原帖:http://www.cnblogs.com/junior/archive/ ...