在C语言中,escape的符号很好用,
比如
"中国一定强"
这个字串可以写成:
"\x4E2D\x56FD\x4E00\x5B9A\x5F3A"
用字元编码编写程序,在其他不同语言的windows运作时,比较不会有问题。
(我尽量不想在程序中写入中文)
但是vb如果全部要用字元编码写的话,就会很麻烦而且一个一个都要手写成:
ChrW(&H4E2D) & ChrW(&H56FD) & ChrW(&H4E00) & ChrW(&H5B9A) & ChrW(&H5F3A)
所以我写了一条短短的function:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function EscToStr(ByVal c As String) As String
Dim tmp, str1, str2, str3, str4 As String
Dim i, outend1, outend2 As Integer
i = 1
outend1 = 1
Do While outend1 <> 0
  ......
在C语言中,escape的符号很好用,
比如
"中国一定强"
这个字串可以写成:
"\x4E2D\x56FD\x4E00\x5B9A\x5F3A"
用字元编码编写程序,在其他不同语言的windows运作时,比较不会有问题。
(我尽量不想在程序中写入中文)
但是vb如果全部要用字元编码写的话,就会很麻烦而且一个一个都要手写成:
ChrW(&H4E2D) & ChrW(&H56FD) & ChrW(&H4E00) & ChrW(&H5B9A) & ChrW(&H5F3A)
所以我写了一条短短的function:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function EscToStr(ByVal c As String) As String
Dim tmp, str1, str2, str3, str4 As String
Dim i, outend1, outend2 As Integer
i = 1
outend1 = 1
Do While outend1 <> 0
  ......
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function lstrcpy Lib "Kernel32.dll" Alias "lstrcpyW" (lpszString1 As Any, lpszString2 As Any) As Long
'通过指针获取字符串的长度
Public Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" (ByVal lpszString As Long) As Long
Public Function FindTextInStr(ByVal OriStr As String, ByVal strText As String) As Long
Dim Buff() As Byte '声明一个Byte数组
Dim Pointer As Long '声明一个变量,用于存储指针
Pointer = StrPtr("Love")
ReDim Buff(0 To lstrlen(Pointer) * 2 - 1) As Byte '分配缓存大小,由于得到的是Unicode,所以乘以2
lstrcpy Buff(0), ByVal Pointer '复制到缓存Buff中
' Me.Caption = InStr(1, Buff, StrConv("o", vbfromUnicod ......
文章来源: http://www.zoesan.com By Error 302777528转载请注明出处
以上vb用到指针技术查找字符串与c#一般的.indexof()查找相比较,明显看出谁快谁慢。
VB:
Option Explicit
'指针方法操作字符串
'Copy一个字符串到缓存中
Public Declare Function GetTickCount Lib "kernel32" () As Long
Public Declare Function lstrcpy Lib "Kernel32.dll" Alias "lstrcpyW" (lpszString1 As Any, lpszString2 As Any) As Long
'通过指针获取字符串的长度
Public Declare Function lstrlen Lib "Kernel32.dll" Alias "lstrlenW" (ByVal lpszString As Long) As Long
Public Function FindTextInStr(ByVal OriStr As String, ByVal strText As String) As Long
Dim Buff() As Byte '声明一个Byte数组
Dim Pointer As Long '声明一个变量,用于存储指针
Pointer = StrPtr("Love")
ReDim Buff(0 To lstrlen(Pointer) * 2 - 1) As Byte '分配缓存大小,由于得到的是Unicode,所以乘以2
lstrcpy Buff(0), ByVal Pointer '复制到缓存Buff中
' Me.Caption = InStr(1, Buff, StrConv("o", vbfromUnicod ......
VC函数是:extern "C" int __declspec(dllexport)PassPortRead(char *InPutData,char OuPutData[255]);
VB声明是:Private Declare Function PassPortRead Lib "PPRead.dll" (ByVal InPutData As String, ByVal OutPutData As String) As Integer
生成的文件能正常运行,并且能生成相应数据,但是在调试时提示"DLL调用约定错误"
E_Mail:linnda413@126.com
VC代码:
int PassPortRead(char *InPutData,char OutPutData[255])
{
char tmp[255];
int len = 0;
memset(tmp,0,255);
//初如化成员变量passInfo
memset(PassInfo.Name,0,20);
memset(PassInfo.Birth,0,20);
memset(PassInfo.Gender,0,10);
memset(PassInfo.Nationality,0,10);
memset(PassInfo.Number,0,20);
memset(PassInfo.IdCode,0,20);
memset(PassInfo.Expiry,0,20);
memset(PassInfo.CIssue,0,20);
//删除换行与回车字符
DelInStr(InPutData,"\r");
DelInStr(InPutData,"\n");
len = strlen(InPutData);
if (len == 0)
{
return -1;
} ......
今天想要做类似金山词霸屏幕取词的功能,在网上找了一些资料,发现都很复杂。既然金山词霸已经实
现了,借用之:
金山词霸中2005中带了一个XdictGrb.dll,其实是一个COM组件,并且实现了一个取词的插件框架。
其中的有以下内容:
1 接口
1.1 GrabProxy 取词代理对象
Function AdviseGrab(XDictGrabSink As IXDictGrabSink) As Long
广播一个XDictGrabSink(如果要实现取词功能,你需要自己来实现这个接口,具体的方法后面会有介绍。(Visual Basic的示例,使用其他语言类似)) 接口,在需要取词的时候会调用XDictGrabSink的QueryWord方法,你可以在这里实现你需要的功能。
Property GrabEnabled As Boolean
是否取词的属性
Property GrabMode As XDictGrabModeEnum
设定取词的属性,XDictGrabFlagEnum的定义后面会讲到。
Property GrabFlag As XDictGrabFlagEnum
设定取词健,比如是否要结合Ctrl或者Shift.
Property GrabSystemCP As Long
这个属性暂时不太清楚。
Sub GrabWord(lCursorX As Long, lCursorY As Long)
取x,y坐标的词,估计是屏幕坐标。
Sub UnadviseGrab(lCookie As Long)
取消对XDictGrabSink接口的广播。
Property XDictGrabPlugins As ......
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required data transfer between my VB.NET WinForms application and the JavaScript (inside an HTML page). Along the way, I hit certain problems, and trying to resolve them cost plenty of time on the web (on Google mostly), so I thought of this article as a platform for developers looking to sort out similar issues. There isn't much detail on this topic on the web apart from a couple of Hello World examples from Microsoft on MSDN.
Starting point
OK, without any further talk, I will dig in to the subject.
Hello World
To start off, we'll start with a very simple example; all this will do is call a JavaScript function from VB.NET to display an alert with message 'Hello world'. Similarly, from the HTML pag ......
※==================================================================
※本连载文章说明:
※1、连载首发于《软件报》(http://www.sweek.com)2006年21期(2006年5月22日);
※2、此次网上连载采用的是原稿件结构,内容与《软件报》发表略有不同;
※3、谢绝除《软件报》及其相关刊物之外的传统媒体部分或全部转载;
※4、谢绝任何收费媒体、网络转载;
※5、原作者:uruseibest ,blog:http://blog.csdn.net/uruseibest;
※6、如有其它疑问,请联系作者;
※7、如有转载,必须连同本说明一并发表,否则将追究转载者责任。
※======================================================================
第一章 前言
Windows 98以上的操作系统在系统目录下都带有iphlpapi.dll这个动态链接库文件,它可以帮助程序员方便地获取计算机网络信息。对于C程序员来说,只要有iphlpapi的头文件,调用iphlpapi.dll是很简单的事,但是对于Vb程序员则是比较困难的问题。本文将就Vb中调用iphlpapi.dll来介绍iphlpapi的使用。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/UruseiBest/archive/2006/12/20/1450351.aspx ......