You are not logged in.

  • "StefanSchnell" is male
  • "StefanSchnell" started this thread

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

1

Friday, January 29th 2010, 12:09pm

WinAPI calls in Jabaco programs for a different OS

Hello community,
a small hint for all who develop applications for different OS:

In Jabaco it is possible and very easy to use the WinAPI. If you use it, you can not run your application, e.g. with Linux OS, this means you can not call a WinAPI function, so you get an exception error. If you want to develop those applications, you can use a global variable to wrap WinAPI calls. Define the variable in the main procedure:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Public Form1 As New Form1

Global Windows As Boolean = False

Public Sub main(ByJava args() As String)

   If LCase(Left(java#lang#System.getProperty("os.name"), 3)) = "win" Then
     Windows = True
   End If

   Dim myArgs() As String
   myArgs = args
   Form1.SetDefaultClose()
   Form1.Show()
End Sub


And you can use it in your code like this:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
Private WinAPI Function MessageBeep Lib "user32.dll" (ByVal wType As Long) As Long

Public Sub Command1_Click()

    If Windows Then
      MessageBeep(1500)
    End If 
    
   MsgBox "Dies ist ein Test"
End Sub


So it is possible to use WinAPI calls with Windows OS and run the application with different OS without native call exception error.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

Rate this thread
WoltLab Burning Board