Results 1 to 6 of 6

Thread: VB.net api?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2007
    Posts
    439

    VB.net api?

    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 .

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: VB.net api?

    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

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: VB.net api?

    Yes there are, and they aren't much different. Here are a couple declarations as examples:

    vb Code:
    1. Declare Ansi Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    2.  
    3.     Declare Ansi Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Integer, ByVal lpString As System.Text.StringBuilder, ByVal nMaxCount As Integer) As Integer
    My usual boring signature: Nothing

  4. #4
    New Member
    Join Date
    Jul 2007
    Location
    Hanoi.VietNam
    Posts
    12

    Post Re: VB.net api?

    this is an Apigen for vb.net 2005.
    very useful !
    http://winrazor.chat.ru/apigen.zip

  5. #5
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: VB.net api?

    remember to change everything from long to integer.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VB.net api?

    ...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
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width