ArcSDE C APi的C#调用
选两个比较有代表性的函数
首先下载安装sdk,将其中的sde.dll,pe.dll和sg.dll拷贝过来
使用如下的代码,指定dll后直接调用其中的函数,
/// <summary>
/// Sets the value for a small integer column.
/// </summary>
[DllImport(".\\sde91.dll", SetLastError = true, ThrowOnUnmappableChar = true)]
public static extern Int32 SE_stream_set_smallint(IntPtr stream, Int16 column, sbyte[] short_val);
/// <summary>
/// Sets the value for a string column.
/// </summary>
[DllImport(".\\sde91.dll", SetLastError = true, ThrowOnUnmappableChar = true)]
public static extern Int32 SE_stream_set_nstring(IntPtr stream, Int16 column, byte[] string_val);
在插入数据时使用到的两个函数,一个是插入string,另一个是插入smallint(short型)
在c#中,string是unicode的,所以需要使用函数SE_stream_set_nstring
此函数的第三个参数如以上代码中的,如果直接写为string,则对于中文字符,出来的就是乱码了
使用byte,然后调用时如下:
ret = Stream.SE_stream_set_nstring(insertStream, 3, (new UnicodeEncoding()).GetBytes("测试"));
对于smallint型,在SE_stream_set_smallint函数中直接使用short,
也出现错误,不知道为什么,后来想到
C#中的sbyte是8位的,两个组成的数组就是一个short(16位有符号整型)
然后试了试,果然可用,
使用的时候注意,比如要存入一个变量ashort;
sbyte[0]中的数值,可以为小于256的值
当数值大于256时(1<<8)
sbyte[1]就是数值ashort>>8;
sbyte[0]为ashor-((ashort>>8)<<8)
使用位运算,简单方便效率高,不知道还有没有其他不需要转换的方法
相关文档:
格式输出:
printf(格式控制, 输出表列);
%d 十进制数 %md m为指定的宽度 若数据位数小于m,则左端补以空格;若大于m,则按实际位数输出
%ld 长整型数据 %mld 指定字段宽度
%o 八进制整数形式 %mo
%x 十六进制整数形式 %mx
%u unsigned型数据,它也可用%o或%x格式输出
%c 一个字符 ......
<select class="wellId" id="gasOriginWellId" name="gasOriginWellId" value="${mechWellForm.gasOriginWellId}" index="true">
< ......
这是我写的第一个博客日志,在此首先测试一下本个博客系统的功能情况,如分类功能,阅读的简易性,代码显示的方式等。
so:添加第一个代码程序,如下:
private void Form1_Load(object sender, EventArgs e)
{//使listView控件支持编辑功能
System.Windows ......
1 前言
长期以来,广大程序员为到底是使用Client/Server,还是使用Browser/Server结构争论不休,在这些争论当中,C/S结构的程序可维护性差,布置困难,升级不方便,维护成本高就是一个相当重要的因素。有很多企业用户就是因为这个原因而放弃使用C/S。然而当一个应用必须要使用C/S结构才能很好的实现其功能的时 ......
单线程
Single-Threaded(static) libc.lib
Debug Single-Threaded(static) & ......