vb.net嵌入c程序 vbnet implements

vb.net 调用C语言可执行程序并传值?

在c语言中每一个变量都有两个属性一个是值,一个是址。比如inta=2;变量a的值是2,变量a的地址,可以用取地址

成都创新互联-云计算及IDC服务提供商,涵盖公有云、IDC机房租用、内蒙古服务器托管、等保安全、私有云建设等企业级互联网基础服务,服务电话:18982081108

操作符

获取,即a。因此以C语言的函数传递中具备两种方式传递参数,一种是传址,一种传值。比如voidf1(intv){;}//函数f1v

怎样在vb.net中插入C语言

如你所说:

.net中包括 vb.net java.net c#.net等.

.net是一个大的平台 它集成了很多中语言就如上面所说的.

你可以选择各种不同的语言来进行开发,个子遵循自己的语言风格.

Asp.net不属于咱们刚才说的那种语言环境当中,它不是个语言.而是一种模式.

ASP.net代表的就是 B/S开发,这个你明白吧?B/S就是 浏览器/服务器的模式.也就是咱们常说的网站开发.

C语言是一门单纯的语言,C语言是一个母语.就像VB的母语是PasCal一样.

.net中以c语言为母语的语言就是C#.net和Java.net两种.

.net可以用来开发网页和软件应用程序.

而C语言只能来写一些操作计算机底层的代码.

这样说可以嘛.

VB.net如何调用C++ DLL,有重谢

如果DLL不是你写的,且你要调用的函数不是__stdcall声明,VB直接调用是会报错的

如果DLL是你写的,注意调用约定问题,并看以下代码

***************************************************

以下是DLL代码

.cpp里这么写

extern "C"__declspec(dllexport) void __stdcall HelloWorld()

{

MessageBox(NULL,"HelloWorld","HelloWorld",NULL);

}

.def里这么写

LIBRARY      "XXXX"

EXPORTS

; 此处以下添加

HelloWorld@1

*************************************************

vb里这么写

Public Declare Sub HelloWorld Lib "XXXX.dll" ()

然后调用就可以了,上面是VB的代码,或许VB.net的也差不多

如何用VB.NET把执行文件加到窗体中

加以一个panel用来显示应用程序的,就是放你那个easycap的,代码如下

Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Int32, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Int32) As Int32

Private Const WM_SYSCOMMAND As Int32 = H112

Private Const SC_MAXIMIZE As Int32 = HF030

Private Const SC_MINIMIZE As Int32 = HF020

Private Const SC_RESTORE As Int32 = HF120

Public Const SW_HIDE = 0

Public Const SW_SHOW = 5

Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Int32, ByVal nCmdShow As Int32) As Int32

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ShellExecute(Me.Panel1.Handle, "open", "c:\windows\system32\cmd.exe", Nothing, ".", SW_HIDE)

System.Threading.Thread.Sleep(50)

Dim h As IntPtr = FindWindow(Nothing, "c:\windows\system32\cmd.exe")

ShowWindow(h, SW_HIDE)

SetParent(h, Me.Panel1.Handle) '嵌到panel1内

SendMessage(h, WM_SYSCOMMAND, SC_MAXIMIZE, 0)

End Sub

把其中的c:\windows\system32\cmd.exe换成你要嵌入的应用程序


分享文章:vb.net嵌入c程序 vbnet implements
转载来于:http://myzitong.com/article/doggcpc.html