In vb6 i could use api functions to say reboot a machine or open a word doc from a VB app.
In vb.net how do i do those things as it has changed. There are no api commands now .
Printable View
In vb6 i could use api functions to say reboot a machine or open a word doc from a VB app.
In vb.net how do i do those things as it has changed. There are no api commands now .
Api commands are accessible. Here's a link to an article http://visualbasic.about.com/od/usin.../WinAPISet.htm and an example here http://www.freevbcode.com/ShowCode.asp?ID=2707
Yes there are, and they aren't much different. Here are a couple declarations as examples:
vb Code:
Declare Ansi Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Declare Ansi Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Integer, ByVal lpString As System.Text.StringBuilder, ByVal nMaxCount As Integer) As Integer
this is an Apigen for vb.net 2005.
very useful !
http://winrazor.chat.ru/apigen.zip
remember to change everything from long to integer.
Quote:
...or open a word doc from a VB app.
Code:Option Explicit On
Option Strict On
'Ad a reference to MS Word xx.0 Object Library
Imports Microsoft.Office.Interop
Public Class Form1
Private oApp As Word.Application
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
oApp.Quit()
oApp = Nothing
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim oDoc As Word.Document
oApp = DirectCast(CreateObject("Word.Application"), Word.Application)
oDoc = oApp.Documents.Open(FileName:="C;\Test.doc")
oApp.Visible = True
'Do stuff like read or write from/to the document
'Close and clean up
oDoc.Close(SaveChanges:=False)
oDoc = Nothing
End Sub
End Class