The windows of DOS program for VB application

Source: Internet
Author: User
Tags net send

In the dual sense, all visual programming tools, VB should be the simplest, quickest, most convenient, I have used it to do the application, edited the game, developed a small plug-in and so on, feel the use of VB although weak point, but through the API can really very convenient to complete a lot of work, Today, I have some experience and methods of adapting my DOS console program to a window application:

1 The simplest way to make a DOS console windowing is to use a shell function, as in MSDN:

Syntax: Shell (pathname [, WindowStyle]), executes an executable file, returns a Variant (Double), if successful, represents the task ID of the program, if unsuccessful, returns 0.

Only need an executable path and Run-time window state on the line, such as the net SEND command to do a windowing program, you can create a new form, and then place two text control and a command button, where Text1 said to fill out the IP address, Text2 fill out the message to send, Finally, this is called in the command's Click event:

Dim Rtn as Variant
RTN = Shell ("Net send" & "& Text1.Text &" & Text2.text, 0) ' parameter 0 indicates hidden DOS window

Here, a net Send window version is done, everyone as long as the interface slightly beautify the OK ~ ~ ~

2) Calling API functions

This way should be said to be the most perfect, after all, is the operating system to provide the function ~ here to use API functions, so to be stated, we will declare it in GM: Private Declare Function winexec Lib "kernel32" (ByVal lpCmdLine as String, ByVal nCmdShow as Long

The next step is similar to the previous, just so called in the command control's Click event:

Dim cmd as String
Dim HWnd as Integer
cmd = "net send" & "& Text1.Text &" "& Text2.text
HWnd = winexec (cmd, 0)

In this way, you can complete the call to the net send command, very convenient, I have done several DOS console program Windows version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.