Alternatives to replace Microsoft Small Basic. Lesson on computer science and ICT on the topic: "Introduction to the Small Basic programming environment" Putting a program into startup

Eclipse is an extensible development platform with runtimes and application platforms for creating, running, and managing software throughout its lifecycle. Many people know Eclipse as a Java IDE, but Eclipse is actually made up of over 60 different open source projects.

Free Open source Mac Windows Linux

  • NetBeans

    Free and open source IDE for developers software. You get all the tools you need to create professional desktop, enterprise, web and mobile applications in Java, C/C++ and even dynamic languages ​​like PHP, JavaScript, Groovy and Ruby

    Free Open source Mac Windows Linux BSD

  • Aptana Studio

    Aptana Studio is a complete web development environment that combines powerful development tools with a suite of online hosting and collaboration services to help you and your team get more done. Includes support for PHP, CSS, FTP and more.

    Free Open source Mac Windows Linux

  • Komodo Edit

    Komodo Edit is a fast, smart and free open source editor. Try using Komodo Edit (or its big brother Komodo IDE) - it's worth it.

    Free Open source Mac Windows Linux

  • Xcode

    Apple's Xcode is the leading development environment for Mac OS X. In addition to being included on the disc with every Mac OS X purchase, it is the most new version is also always available for free download for ADC members ( social network for app developers on all Apple platforms) and includes all the tools you need to create, tweak, and optimize the apps you create

    Free Mac

  • MonoDevelop

    MonoDevelop is a cross-platform IDE primarily designed for C# and other .NET languages. MonoDevelop allows developers to quickly create desktop and ASP.NET web applications for Linux, Windows and Mac OSX. MonoDevelop allows developers to easily port .NET applications built in Visual Studio to Linux and Mac OSX, supporting single base code for all platforms

    Free Open source Mac Windows Linux. NET Framework Xamarin Studio

  • Lazarus

    Free Pascal is a GPL compiler that runs on Linux, Win32, OS/2, 68K and more. Free Pascal is designed to understand and compile Delphi syntax. Lazarus is the piece of the missing puzzle that will allow you to develop Delphi-like programs for all of the above platforms. Since the same compiler is available on all of the above platforms, this means you don't have to re-code to create identical products for different platforms

    Free Open source Mac Windows Linux BSD OpenSolaris

  • WebStorm

    JetBrains WebStorm is a commercial development environment for JavaScript, CSS and HTML built on the JetBrains IntelliJ IDEA platform.
    WebStorm provides automatic code completion, on-the-fly code analysis, refactoring support, and VCS integration.

    Paid Mac Windows Linux

  • SharpDevelop

    #develop (short for SharpDevelop) is a free development environment for C#, VB.NET and Boo projects in Microsoft platform. It is an open source environment. You can download as source code, and executable files.

  • Basics of programming.

    Programming language Small Basic

    LESSON 1: Introduction to the programming environment Small Basic .

    Target: Introduce with the Small Basic programming language.

    Tasks:

      Start learning a programming language Small Basic. Give the concept of OOP (object-oriented programming)

      Learn to work in this programming environment. P familiarize yourself with the “text object” of the environment Small Basic.

      Give a first idea of ​​creating programs in a programming environment.

    The main educational objectives of the project:

      Nurturing personal qualities: dedication, attentiveness, accuracy, objectivity in self-esteem, responsibility, cognitive interest.

    Main development tasks of the project:

      To develop in students key competencies that contribute to successful social adaptation;

      Develop a desire for self-development and personal growth through cognitive activity.

    Know: Basic concepts: object, variables, assignment, data types, input-output.Know the constituent elements of the Small Basic programming environment.

    Be able to: Download the Smal Basic program. Create simple projects in this programming environment. Be able to enter mathematical functions and write mathematical expressions in the Smal Basic language. Write simple linear programs.

    Equipment and material: supporting lecture notes (seeAppendix 1 ), task cards, PC, Small Basic application, board, multimedia projector, screen.

    Lesson progress:

      Organizational moment

      1. Preparing for the lesson

        Updating knowledge

      Explanation of new material

      Reinforcing the material learned

      1. Questions on the topic

      Summing up

      1. Grading

        Homework

      Organizational moment

      1. Preparation for the lesson (check readiness for the lesson, mark those absent)

        Updating knowledge

    Why is programming needed?

    You want to write an essay on biology. Most likely, you will write it on your computer in some text editor. Where did the text editor come from? Of course, it was written by programmers. You will search for information on the Internet using a browser that was also written by programmers. After you write your essay, you will want to relax and play computer game, which was again written by programmers. In general, working on a computer is impossible without using programs that programmers write. This means that if there were no programming, there would be no programs, and the computer would be a pile of expensive hardware, because it is impossible to do something using a computer without programs.

    Stages of problem solving.

    Basic Concepts

    Programming - writing programs.

    Program - an algorithm written in a programming language that a computer can understand.

    Algorithm – a clear sequence of actions aimed at achieving the goal.

    In object-oriented programming the concept of an object was introduced, calculation mechanisms were implemented, allowing:

      Describe the structure of an object

      Describe actions with objects

      Use special object inheritance rules (Inheritance means creating new objects from existing ones)

      Set the degree of protection of object components

      Theory

    First acquaintance

    Microsoft Small Basic - a programming language developed by . Designed for beginner developers who want to learn the basics of creating programs.

    Main advantages:

      A very simple development environment - a text editor with a multifunctional tooltip and only a few buttons for editing text and launching programs.

      Simple language with only 20 keywords

      Contextual documentation for all language elements built into the development environment

      The ability to extend Small Basic components to include additional functionality. (For example, the delivery already includes capabilities for working with services)

      A special advantage of BASIC is the ability to work in interpretation mode, which greatly simplifies the process of debugging programs: the execution of almost every command can be checked immediately after writing.

    Inference operator

    WriteLine("Hello!")

    Displays the string (text or number )

    Hello!

    To get the result - displaying the text “Hello!” to the screen - you need to write a program:

    TextWindow.WriteLine("Hello!")

    The program is entered into the windowSmallBasicand starts with a buttonLaunch or key F 5

    The result of the program is the text output: "Hello!" VText box programs.

    The line means “Press any key to continue...”

    TextWindow is a “text window” object in which text can be displayed.

    The object has properties And methods.

    Object method -what an object can do, i.e. itoperations (operators )

    Parameter The operation is enclosed in the WriteLine parentheses()

    Also an object text box has properties (these are the characteristics of the object) , For example

    BackgroundColor property – sets the background color for the text,ForegroundColor- text color


    Colors:

    red

    yellow

    green

    blue

    black

    white

    red

    yellow

    green

    blue

    black

    white

    Variable

    Variables are often used to create programs.

      The variable hasName - Latin letter (a)

      A variable can be assigned a value, such as a numeric value

    a= 5, where the sign " = " - This assignment operator

    String value

    a = a + 5

      Take the value of variable a

      Add 5 to it

      Put a new value in variable a, erasing the previous one from it

      There are two types of variable: number And line

    10, -5, 3.14 “computer science”

    Fold +

    Multiply *

    Divide /

    Mathematical operations:

    Sine, logarithm, root

    Glue

    Divide into parts

    Search symbols

    Replace characters

    EXAMPLE with operator "+"

    expression

    result

    expression

    result

    "Ivan" + "ova"

    "Ivanova"

    "class"+ 10

    "class10"

    Programming

    Example 1: program result

    Example 2: program result

    Example 3: The program calculates and displays the sum of two variablesa And b

    Math.Abs(number)

    module

    Math.Cos( number)

    cosine

    Math.Ceiling(number)

    rounds to a whole number

    Math.GetDegrees( number)

    converting numbers from radians to degrees

    Math.GetRandomNumber( maxnumber)

    Random number in the range from 1 tomaxnumber

    NaturalLog(number)

    Natural logarithm

    Math.Pi

    Pi number

    Math.Power( baseNumber, exponent)

    IN oconverting baseNamber to exponent

    Math. Max (number1, number2)

    Maximum of two numbers

    Math. Remainder(dividend, divisor)

    Remainder of division

    Math .Sin(number)

    Sinus

    Math. Tan(number)

    Cosine

    Math .SquareRoot(number)

    Root

    Math. Round(number)

    Normal rounding

    Math .ArcSin(number)

    arcsine

    Math. Floor(number)

    Rounds to the nearest smallest integer

    x=TextWindow.ReadNumber()

    y=Math.Abs(x)

    TextWindow.WriteLine("y equals "+y)

    Math.Pi

      Fixing the material

      1. Independent practical work for PC

    Tasks for independent work

    Task 1:

    Determine the end results of assignment statements

    X=3

    Y=2

    X=X+2

    Y=X*2

    X=Y

    A= 15

    B=A

    A=B/5+2

    B=A*3

    A=0

    Task 2 : Create a program for calculating the product of 3 variables:a , b And c .

    Task 3 : Create a program to calculate the expression:z=5* x+ y/2 (assuming x=10,y=100)

    Task 4: Create a program to display the values ​​of X andY, according to task 1.

    Task 5: Create a program to find the discriminant

    Task 6 : evaluate expressions

      (5+5) 3 (1000 )

      2+|3-25| (24 )

      4 2 – (10)

      Cos 2 (Pi/4)+ Sin 2 (Pi/2) (1 )

      ( 1)

      Y=2x 2 ( at x=5, y=50)

      X 1.2 = (at a=2, b=6, c=4 , x 1=-1, x 2=-2)

      Z= ln(y)-3 ( at y=3, z=-1.901…)

      C= (at a=4, b=9, c=13)

      Y=cos(x)+sin(x) (x=180 0 , y=-1)

      Questions

      What is the program?

      What are programming languages ​​for?

      What are the basic elements of object-oriented programming?

      What operations can be performed in the “text window”?

      What does the assignment operator mean:

      What types of data are used in Small Basic?

      How are I/O statements written?

      Summing up

      1. Grading

        Homework

      Job with supporting notes

      prepare a message on the topic: “Varieties of programming languages”

      Make a program calculating the area of ​​a triangle using Heron's formula

    Application

    OK 1: Basics of programming in the language Small Basic .

    Programming - writing programs.

    ALGORITHM + PROGRAMMING LANGUAGE= PROGRAM

    Variable

      The variable hasName - Latin letter (For example,a , IN , x1 , C9 )

      A variable can be assigned a value

    Example: a = 5 , where the sign " = " - This assignment operator

      There are two types of variable: number And line (sequence of characters)

    10, -5, 3.14 “computer science”

    Fold +

    Multiply *

    Divide /

    Mathematical operations:

    Sine, logarithm, root

    Glue

    Divide into parts

    Search symbols

    Replace characters

    Programming

    TextWindow- This text window object , in which you can display text.

    Operation parameter enclosed in parentheses - WriteLine()

    Object text box has properties , For example

    Property BackgroundColor – sets the background color for the text,ForegroundColor - text color

    Colors used:

    red

    yellow

    green

    blue

    black

    white

    red

    yellow

    green

    blue

    black

    white

    Small Basic Language Operators

    "+" operator

    Basic operators

    Using Mathematical Functions in an Expression

    Composing complex mathematical expressions Math.Pi TextWindow.WriteLine("enter the value of variable x")

    x=TextWindow.ReadNumber()

    y=Math.Abs(x)

    TextWindow.WriteLine("y equals "+y)

    TextWindow.WriteLine(Math.Abs(-10))

    Program for calculating the sum of two variablesA And b

    TextWindow.WriteLine("enter the value of variable a")

    a=TextWindow.ReadNumber()

    TextWindow.WriteLine("enter the value of variable b")

    b=TextWindow.ReadNumber()

    s=a+b

    TextWindow.WriteLine(" the sum of the numbers is equal "+s)

    The program is entered into the windowSmallBasicand starts with a buttonLaunch or key F 5.

    Line Press any key continue ...means " Press any key to continue

    Hello everyone, in this article I want to show you useful codes for small programs. Which you can use to write your own more serious programs, or you were looking for exactly these functions that are described here.

    All codes were used in the programming environment Microsoft Visual Basic v6.0.

    Exit with confirmation

    The first kind of program, or function, is an exit with a message confirming the exit. In general, open the environment Visual programming Basic, create a standard project, then place one button on the form, click on the button and a code editing window will open, and you need to insert the following code there:

    Beep Dim message As String Dim buttonsandicons As Integer Dim title As String Dim response As String message = "Do you want to go out?" title = "Exit" buttonasicons = vbYesNo + vbQuestion response = MsgBox(message, buttonasicons, title) If response = vbYes Then End End If !}

    Password to start the program

    Dim Password, Pword PassWord = "12345" Pword = InputBox("Enter password") If Pword<>PassWord Then MsgBox "Password is not correct" End End If

    Where, 12345 is the password to start the program. But this code can be used wherever you want.

    Message output

    If you just want to display a message for something, then paste this:

    Beep Dim message As String Dim buttonsandicons As Integer Dim title As String message = "Message" title = "Message" buttonasicons = vbOKOnly + vbexciamation MsgBox message, buttonsandicons, title !}

    Drawing on the form

    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Form1.CurrentX = X Form1.CurrentY = Y End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Line (Form1.CurrentX, Form1.CurrentY)-(X, Y), QBColor(0) End If End Sub

    You can change the color using the QBColor(0) parameter, i.e. Instead of 0, put another number.

    Restarting the computer

    To reboot your computer: place the button and paste the following code:

    Dim strComputer As String strComputer = "." Set objWMIService = GetObject("winmgmts:" & "(impersonationLevel=impersonate, (Shutdown))!\\" _ & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each ObjOperatingSystem In colOperatingSystems ObjOperatingSystem.Reboot " To reboot Next

    Launching a program in a single copy

    The following example will help you make the program run only once, i.e. if it is restarted, it will display a corresponding message. Insert the following into the form code:

    Private Sub Form_Load() If App.PrevInstance = True Then MsgBox "The project has already started!" End End If

    Turning off the computer

    To turn off your computer you can use the following code:

    Dim strComputer As String strComputer = "." Set objWMIService = GetObject("winmgmts:" & "(impersonationLevel=impersonate,(Shutdown))!\\" _ & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each ObjOperatingSystem In colOperatingSystems ObjOperatingSystem.ShutDown "To shut down Next

    Ending any process

    To terminate the process you can use the following code:

    Shell "Cmd /x/c taskkill /f /im ICQlite.exe", vbvhite

    Where, instead of ICQlite.exe there can be any process.

    How long does the computer last?

    Below is an example of how you can determine the computer's operating time. This method is based on the use of the kernel32 library, so at the very beginning of the form code, connect this DLL.

    Private Declare Function GetTickCount Lib "kernel32" () As Long "And in the button code: Dim a_hour, a_minute, a_second a = Format(GetTickCount() / 1000, "0") "total seconds a_days = Int(a / 86400) a = a - a_days * 86400 a_hour = Int(a / 3600) a = a - a_hour * 3600 a_minute = Int(a / 60) a_second = a - a_minute * 60 MsgBox "Your computer is running " & Str(a_days) & " days " & Str(a_hour) _ & " hours " & Str(a_minute) & " minutes" & Str(a_second) & " seconds"

    We have reviewed simple functions, which can be used almost anywhere. Now let's look at more serious examples, and they can greatly help you write your large projects.

    Examples of working with folders

    Delete directory

    Private Declare Function RemoveDirectory& Lib _ "kernel32" Alias ​​"RemoveDirectoryA" (ByVal lpPathName As String) "Removing directory (empty!) PathName$ = "D:\t" code& = RemoveDirectory(PathName) If code& = 0 Then "Error removing directory Else "Directory deleted End If

    Create directory

    Sub MakeDir(dirname As String) Dim i As Long, path As String Do i = InStr(i + 1, dirname & "\", "\") path = Left$(dirname, i - 1) If Right$(path , 1)<>":" And Dir$(path, vbDirectory) = "" Then MkDir path End If Loop Until i >= Len(dirname) End Sub Private Sub Command1_Click() Call MakeDir("C:\Soft\1\2\3\ ") End Sub

    List all folders with sub folders

    We add 2 text fields and a button to the form, the name of the first text field is StartText, the name of the second text field is OutText. Multiline property = true, button name = CmdStart

    Static running As Boolean Dim AllDirs As New Collection Dim next_dir As Integer Dim dir_name As String Dim sub_dir As String Dim i As Integer Dim txt As String If running Then running = False CmdStart.Enabled = False CmdStart.Caption = "Stopping" Else running = True MousePointer = vbHourglass CmdStart.Caption = "Stop" OutText.Text = "" DoEvents next_dir = 1 AllDirs.Add StartText.Text Do While next_dir<= AllDirs.Count dir_name = AllDirs(next_dir) next_dir = next_dir + 1 sub_dir = Dir$(dir_name & "\*", vbDirectory) Do While sub_dir <>"" If UCase$(sub_dir)<>"PAGEFILE.SYS" And sub_dir<>"." And sub_dir<>".." Then sub_dir = dir_name & "\" & sub_dir On Error Resume Next If GetAttr(sub_dir) And vbDirectory Then AllDirs.Add sub_dir End If sub_dir = Dir$(, vbDirectory) Loop DoEvents If Not running Then Exit Do Loop txt = "" For i = 1 To AllDirs.Count txt = txt & AllDirs(i) & vbCrLf Next i OutText.Text = txt MousePointer = vbDefault unning = False End If

    Now we launch the program, write in the StartText text field: C:\windows, and click on the button.

    Directory size

    Const MAX_PATH = 260 Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End Type Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14 End Type Private Declare Function FindFirstFile Lib _ "kernel32" Alias ​​"FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile Lib _ "kernel32" Alias ​​"FindNextFileA" (ByVal hFindFile As Long, ileData As WIN32_FIND_DATA) As Long Private Declare Function FindClose Lib _ "kernel32" (ByVal hFindFile As Long) As Long Public Function SizeOf(ByVal DirPath As String) As Double Dim hFind As Long Dim fdata As WIN32_FIND_DATA Dim dblSize As Double Dim sName As String Dim x As Long On Error Resume Next x = GetAttr(DirPath) If Err Then SizeOf = 0: Exit Function If (x And vbDirectory) = vbDirectory Then dblSize = 0 Err.Clear sName = Dir$(EndSlash(DirPath) & "*.* ", vbSystem Or vbHidden Or vbDirectory) If Err.Number = 0 Then hFind = FindFirstFile(EndSlash(DirPath) & "*.*", fdata) If hFind = 0 Then Exit Function Do If (fdata.dwFileAttributes And vbDirectory) = vbDirectory Then sName = Left$(fdata.cFileName, InStr(fdata.cFileName, vbNullChar) - 1) If sName<>"." And sName<>".." Then dblSize = dblSize + SizeOf(EndSlash(DirPath) & sName) End If Else dblSize = dblSize + fdata.nFileSizeHigh * 65536 + fdata.nFileSizeLow End If DoEvents Loop While FindNextFile(hFind, fdata)<>0 hFind = FindClose(hFind) End If Else On Error Resume Next dblSize = FileLen(DirPath) End If SizeOf = dblSize End Function Private Function EndSlash(ByVal PathIn As String) As String If Right$(PathIn, 1) = "\" Then EndSlash = PathIn Else EndSlash = PathIn & "\" End If End Function Private Sub Form_Load() "Replace "D:\soft" with the directory whose size you want to know MsgBox SizeOf("D:\soft") / 1000000 End Sub

    Examples of working with files

    Copy

    Let's say we have a file named 1.txt in the C:\1\ folder, and we need to copy it to C:\2\ to do this we write the following code:

    Filecopy "C:\1\1.txt","C:\2\1.txt"

    Note! If directory 2 already contains a file named 1.txt, it will be replaced with 1.txt from directory 1.

    Private Declare Function CopyFile Lib _ "kernel32.dll" Alias ​​"CopyFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long Private Sub Command1_Click() " Copy file C:\1.txt to D :\1.txt. Dim retval As Long " return value "Copy the file retval = CopyFile("C:\1.txt", "D:\1.txt", 1) If retval = 0 Then "If error MsgBox " I can't copy" Else "If everything is fine MsgBox "File copied." End If End Sub

    Removal

    For example, we want to delete file 1.txt from the root of the C:\ drive

    Kill("C:\1.txt")

    API method

    Private Declare Function DeleteFile Lib _ "kernel32.dll" Alias ​​"DeleteFileA" (ByVal lpFileName As String) As Long Private Sub Command1_Click() "Delete file C:\Samples\anyfile.txt Dim retval As Long "Return value retval = DeleteFile( "C:\1.txt") If retval = 1 Then MsgBox "The file was successfully deleted." End Sub

    Moving

    You can, for example, move it like this:

    Filecopy "C:\1.txt","C:\2\1.txt" Kill ("C:\1.txt")

    But it's better like this (via API):

    Private Declare Function MoveFile Lib _ "kernel32.dll" Alias ​​"MoveFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long Private Sub Command1_Click() Dim retval As Long "Return value retval = MoveFile("C:\1 .txt", "C:\2\1.txt") If retval = 1 Then MsgBox "Moved successfully" Else MsgBox "Error" End If End Sub

    Renaming

    In order to rename the file 1.txt located in C:\ to 2.txt you can use the following code:

    Filecopy "C:\1.txt","C:\2.txt" Kill ("C:\1.txt")

    API method

    Private Declare Function MoveFile Lib _ "kernel32.dll" Alias ​​"MoveFileA" _ (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long Private Sub Command1_Click() Dim retval As Long " return value retval = MoveFile("C:\1 .txt", "C:\2.txt") If retval = 1 Then MsgBox "Success" Else MsgBox "Error" End If End Sub

    Determine file size

    The file size can be determined in two ways:

    If the file can be opened with the OPEN function, then you can use the LOF function

    Dim FileFree As Integer Dim FileSize As Long FileFree = FreeFile Open "C:\WIN\GENERAL.TXT" For Input As FileFree FileSize = LOF(FileFree) Close FileFree

    Or use the FileLen function

    Dim lFileSize As Long FileSize = FileLen("C:\WIN\GENERAL.TXT")

    Hide clock programmatically

    Add 2 buttons and paste the code:

    Option Explicit Private Declare Function FindWindow Lib _ "user32" Alias ​​"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib _ "user32" Alias ​​"FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function ShowWindow Lib _ "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Dim hnd As Long Private Sub Command1_Click() ShowWindow hnd, 0 End Sub Private Sub Command2_Click() ShowWindow hnd, 1 End Sub Private Sub Form_Load() hnd = FindWindow("Shell_TrayWnd", vbNullString) hnd = FindWindowEx(hnd, 0, "TrayNotifyWnd", vbNullString) hnd = FindWindowEx(hnd, 0, "TrayClockWClass", vbNullString) Command1.Caption = "Hide clock" Command2.Caption = "Show clock" End Sub

    Add tray icon

    Add a module and paste the code into it:

    Declare Function Shell_NotifyIconA Lib _ "SHELL32" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Integer Public Const NIM_ADD = 0 Public Const NIM_MODIFY = 1 Public Const NIM_DELETE = 2 Public Const NIF_MESSAGE = 1 Public Const NIF_ICON = 2 Public Const NIF_TIP = 4 Type NOTIFYICONDATA cbSize As Long hWnd As Long uID As Long uFlags As Long uCallbackMessage As Long hIcon As Long szTip As String * 64 End Type Public Function SetTrayIcon(Mode As Long, hWnd As Long, Icon As Long, tip As String) As Long Dim nidTemp As NOTIFYICONDATA nidTemp.cbSize = Len(nidTemp) nidTemp.hWnd = hWnd nidTemp.uID = 0& nidTemp.uFlags = NIF_ICON Or NIF_TIP nidTemp.uCallbackMessage = 0& nidTemp.hIcon = Icon nidTemp.szTip = tip & Chr$( 0) SetTrayIcon = Shell_NotifyIconA(Mode, nidTemp) End Function

    To use, insert into the form code:

    Private Sub Form_Load() SetTrayIcon NIM_ADD, Me.hWnd, Me.Icon, "Test" End Sub "To delete a Private Sub Command1_Click() SetTrayIcon NIM_DELETE, Me.hWnd, 0&, "" End Sub

    Blocking the start button

    Private Declare Function FindWindow Lib "user32" Alias ​​"FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias ​​"FindWindowExA" _ (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function EnableWindow Lib "user32" _ (ByVal hwnd As Long, ByVal fEnable As Long) As Long Public Sub EnableStartButton(Optional Enabled As Boolean = True) Dim lHwnd As Long " find hWnd lHwnd& = FindWindowEx(FindWindow("Shell_TrayWnd", ""), 0&, "Button", vbNullString) Call EnableWindow(lHwnd&, CLng(Enabled)) End Sub Private Sub Command1_Click() EnableStartButton False "START button is disabled End Sub Private Sub Command2_Click() EnableStartButton True "START button is not disabled End Sub

    Reading parameters from the INI file

    The program connects to FTP, and the ini file contains the parameters - server, login, port, password.

    First, create an INI file:

    Servname=server usern=Login pwd=password port=port

    It must be placed in the program folder. Next, insert into the module:

    Private Declare Function WritePrivateProfileString Lib _ "kernel32" Alias ​​"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, _ ByVal lpString As String, ByVal lpFileName As String) As Long Private Declare Function GetPrivateProfileString Lib _ "kernel32" Alias ​​"GetP rivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, _ ByVal lpDefault As String, ByVal lpReturnedString As String, _ ByVal nSize As Long, ByVal lpFileName As String) As Long Public Function ReadIni(Razdel As String, Param) As String ReadIni = GetValue (Razdel, Param, App.Path & "\test.ini", "0") End Function Private Function GetValue(ByVal Section As String, _ ByVal Key As String, ByVal fFileName As String, Optional ByVal DefaultValue As String = vbNullString) As String Dim Data As String Data = String$(1000, Chr$(0)) If GetPrivateProfileString(Section, Key, DefaultValue, Data, 1000, fFileName) > 0 Then GetValue = Left$(Data, InStr(Data$, Chr $(0)) - 1) Else GetValue = DefaultValue End If Exit Function End Function

    Then paste into the form code:

    Private Declare Function InternetOpen Lib _ "wininet.dll" Alias ​​"InternetOpenA" (ByVal sAgent As String, ByVal nAccessType As Long, ByVal sProxyName As String, _ ByVal sProxyBypass As String, ByVal nFlags As Long) As Long Private Declare Function InternetConnect Lib _ "wininet.dll" Alias ​​"InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, _ ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal nService As Long, _ ByVal dwFlags As Long, ByVal dwContext As Long) As Long Private Declare Function FtpPutFile Lib _ "wininet.dll" Alias ​​"FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean Private Declare Function FtpGetFile Lib _ "wininet.dll" Alias ​​"FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _ ByVal dwFlags As Long, ByVal d wContext As Long ) As Boolean Private Declare Function InternetCloseHandle Lib _ "wininet.dll" (ByVal hInet As Long) As Integer Dim rc& Dim rs&

    And in the button code:

    rc& = InternetOpen("", 0, vbNullString, vbNullString, 0) rs& = InternetConnect(rc&, ReadIni("General", "servname"), "0", _ ReadIni("General", "usern"), ReadIni( "General", "pwd"), 1, 0, 0) If FtpGetFile(rs&, "Your file.txt", "path where", False, 0, 1, 0) = False Then End Call InternetCloseHandle(rs&) Call InternetCloseHandle(rc&)

    List of running processes

    Add a Listbox and 1 button, insert the following code:

    Option Explicit Private Declare Function CreateToolhelpSnapshot Lib _ "Kernel32" Alias ​​"CreateToolhelp32Snapshot" _ (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function ProcessFirst Lib _ "Kernel32" Alias ​​"Process32First" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function ProcessNext Lib _ "Kernel32" Alias ​​"Process32Next" _ (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long) Private Const TH32CS_SNAPPROCESS As Long = 2& Private Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Di m hSnapShot As Long Dim uProcess As PROCESSENTRY32 Dim r As Long Private Sub Command1_Click() List1.Clear hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) If hSnapShot = 0 Then Exit Sub End If uProcess.dwSize = Len(uProcess) r = ProcessFirst(hSnapShot, uProcess) Do While r List1.AddItem uProcess.szExeFile r = ProcessNext(hSnapShot, uProcess) Loop Call CloseHandle(hSnapShot) End Sub

    Putting a program into startup

    In order for the program to load with Windows, like some other programs, you can use the registry:

    Add 2 buttons and the following code:

    Private Sub Command1_Click() "Registry entry Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\Name of your program", _ "Path to your program" End Sub Private Sub Command2_Click() "Delete from the registry Set Reg = CreateObject("WScript.Shell") Reg.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\Name of your program" End Sub

    And in order for the program to load along with Windows, even in safe mode, then this code:

    First, a more serious method (do it just in case backup copy registry).

    Private Sub Command1_Click() Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Shell", _ "Path to your program" End Sub Private Sub Command2_Click()" This is for recovery Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Shell", _ "Explorer.exe," End Sub

    Well, a simple way.

    Private Sub Command1_Click() Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit", _ "C:\\WINDOWS\\system32\\userinit.exe ,The path to your program" End Sub Private Sub Command2_Click()"To restore Set Reg = CreateObject("WScript.Shell") Reg.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\Userinit", _ "C: \\WINDOWS\\system32\\userinit.exe," End Sub

    Hiding the taskbar

    Add 2 buttons and paste the code:

    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _ ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _ ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Declare Function FindWindow Lib "user32" Alias ​​"FindWindowA" _ (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const SWP_HIDEWINDOW = &H80 Const SWP_SHOWWINDOW = &H40 "Hide Private Sub Command1_Click() hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) End Sub "Shows Private Sub Command2_Click() hwnd1 = FindWindow("Shell_traywnd", "") Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW) End Sub

    Unzip RAR archive

    In order to unzip the RAR archive, you can use the following code:

    WinRarApp = "C:\Program Files\WinRAR\WinRAR.exe x -o+" iPath = "C:\" iArhivName = "File name.rar" adr = WinRarApp & " """ & iPath & iArhivName & """ " "" & iPath & """ " RetVal = Shell(adr, vbHide)

    How much RAM is in the computer

    Add one button and paste the following code:

    Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As TMemoryStatus) Private Type TMemoryStatus dwLength As Long dwMemoryLoad As Long dwTotalPhys As Long dwAvailPhys As Long dwTotalPageFile As Long dwAvailPageFile As Long dwTotalVirtual As Long dwAvailVirtual As Long End Type Dim s As TMemoryStatus Private Sub Command1_Click( ) ms.dwLength = Len(ms) Call GlobalMemoryStatus(ms) MsgBox "Total:" & ms.dwTotalPhys & vbCr & "Free:" _ & ms.dwAvailPhys & vbCr & "Used in %:" & ms.dwMemoryLoad End Sub

    Hide desktop icons

    This is done as follows. Add 2 buttons and paste the following code:

    Private Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal nCmdShow&) Private Declare Function FindWindow Lib _ "user32" Alias ​​"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const SW_HIDE = 0 Const SW_NORMAL = 1 Private Sub Command1_Click() Dim hHandle As Long hHandle = FindWindow("progman", vbNullString) Call ShowWindow(hHandle, SW_HIDE) End Sub Private Sub Command2_Click() Dim hHandle As Long hHandle = FindWindow("progman", vbNullString) Call ShowWindow(hHandle , SW_NORMAL) End Sub

    Using the Command1 button, the icons are hidden, Command2 - they appear.

    That's all for me, I hope the above examples will be useful to you, bye!

    Share