[VB.NET] Reading and Writing to the Registry

This is a piece from my Final fantasy 11 Configurator that I made back when I used to play the game.

  1. Imports Microsoft.Win32

We’ll now make a registrykey variable.

  1. Dim FF_key As RegistryKey

Now we will make sure the location want it stored in that variable.

  1. FF_key = Registry.LocalMachine.OpenSubKey("\Software\Microsoft\", True)

Now to read in the Keys that are already saved by the game. In this part I called a few keys that I wanted information from, so in order to do that I first declare my variables:

  1. Dim key_windowed_mode As String
  2. Dim key_res_1 As String
  3. Dim key_res_2 As String
  4. Dim key_3D_res_1 As String
  5. Dim key_3D_res_2 As String
  6. Dim key_texture_compress As String
  7. Dim key_on_screen_map As String
  8. key_res_1 = FF_key.GetValue("0001")
  9. key_res_2 = FF_key.GetValue("0002")
  10. key_3D_res_1 = FF_key.GetValue("0003")
  11. key_3D_res_2 = FF_key.GetValue("0004")
  12. key_texture_compress = FF_key.GetValue("0018")
  13. key_on_screen_map = FF_key.GetValue("0019")

The (“numbers”) is the key name which holds the information that I wanted.
Now when it comes to writing it’s just as easy:

  1. FF_key.SetValue("0034", 1, RegistryValueKind.DWord

Valuekind.dword is just the datatype, you don’t always needs to do this but for this to work for me in this case I had to.

Posted in Programming, VB.NET | Leave a comment

[VB.NET][C#] Multi-thread / Crossthreading Example

Someone was asking how to do multi-threading in the shoutbox and my original example didn’t work because of cross-threads. This basically means I couldn’t set the value of a control within a thread since it’s considered a different process. Well I did manage to get it to work and I figured I’d post the code here. I will also include the source code both both the VB.net and C# versions below.

VB

  1. Imports System.Threading
  2. Public Class Form1
  3.  
  4. Dim Max As Double = 600000
  5. Dim i As Integer = 0
  6. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7. ProgressBar1.Maximum = Max
  8. Dim threadFill As Thread = New Thread(AddressOf Thread_FillProgressbar)
  9. threadFill.Start()
  10. End Sub
  11.  
  12. Private Sub Thread_FillProgressbar()
  13.  
  14. For i = 0 To Max
  15. AccessControl()
  16. Next
  17. End Sub
  18.  
  19. Private Sub AccessControl()
  20. If Me.InvokeRequired Then
  21. Me.Invoke(New MethodInvoker(AddressOf AccessControl))
  22. Else
  23.  
  24. ProgressBar1.Value = i
  25. ShowInTaskbar = True
  26. End If
  27. End Sub
  28. End Class

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Threading;
  10. namespace CSharp_multithreading
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19. int Max = 60000;
  20. int i = 0;
  21. private void Form1_Load(object sender, EventArgs e)
  22. {
  23. progressBar1.Maximum = Max;
  24. Thread threadFill = new Thread(Thread_FillProgressBar);
  25. threadFill.Start();
  26. }
  27.  
  28. private void Thread_FillProgressBar()
  29. {
  30. for (i = 0; i <= Max; i++)
  31. {
  32. accessControl();
  33. }
  34. }
  35.  
  36. private void accessControl()
  37. {
  38. if (InvokeRequired)
  39. {
  40.  
  41. Invoke(new MethodInvoker(accessControl));
  42.  
  43. }
  44. else
  45. {
  46. progressBar1.Value = i;
  47. ShowInTaskbar = true;
  48.  
  49. }
  50.  
  51. }
  52. }
  53. }

VB.NET Source

C# Source

Posted in C#, Programming, VB.NET | Leave a comment

VB.NET Detect Key Presses

This bit of code will allow you to detect key presses while the form is not the active window. I currently use this for macros and for my trainer programs for turning on cheats.

All you need to have is a timer on the form. You can either drag and drop one on the form or declare it in code and write the timer.Tick event.

In this example I check for 2 key presses.

  1. Dim altkey As Boolean
  2. Dim Num_1 As Boolean
  3. Dim Num_2 As Boolean
  4. Dim Num_3 As Boolean
  5.  
  6. Private Sub tmr_Keys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_Keys.Tick
  7. altkey = GetAsyncKeyState(Keys.LMenu)
  8. Num_1 = GetAsyncKeyState(Keys.NumPad1)
  9. Num_2 = GetAsyncKeyState(Keys.NumPad2)
  10. Num_3 = GetAsyncKeyState(Keys.NumPad3)
  11. If altkey And Num_1 = True Then 'Infinite Health Player 1
  12. btn_P1InfiniteHealth_Click(sender, e)
  13. ElseIf altkey And Num_2 = True Then
  14. btn_P1InfiniteKi_Click(sender, e) ' Infinite Ki Player 1
  15. ElseIf altkey And Num_3 = True Then
  16.  
  17. End If
  18. End Sub
Posted in Programming, VB.NET | Leave a comment

VB.NET Setting an External Program’s Title window

I have been working on making some trainers for some games and I wanted a basic way of showing that a cheat was enabled.
I couldn’t figured out how to draw to the screen so I figured the title bar would be fine.

  1. Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As IntPtr, ByVal lpString As String) As Boolean
  2.  
  3. Public Sub SetTitleText(ByVal processName() As Process, ByVal textToSend As String)
  4.  
  5. For Each proc In processName
  6. SetWindowText(proc.MainWindowHandle, textToSend)
  7. Next
  8.  
  9. End Sub

The code above will allow you to set the title window to an external program.
An example on how to use it

  1. Dim notepad() As Process = Process.GetProcessesByName("notepad")
  2.  
  3. Private Sub btn_Notepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Notepad.Click
  4. SetTitleText(notepad,"Insert some text here")
  5. End Sub
Posted in Programming, VB.NET | Leave a comment

VB.NET Using a Binary File as a resource

This was something I used in order to try and keep my programs down to 1 file. Instead of including a seperate file that handled the updating, I simply embedded it into the main program. To do this all I did was make it a resource and when I needed to use it I would write it out to the root directory that the program was in.

To add a file as a resource, right click your project and click properties.

Click on the Resources tab. On the top click on strings and select files. Drag and drop the file you want to include as the resource into this window.

Click save or save all.

Now when you decide you need to use that file you can write it out to a directory then run it.

  1. IO.File.WriteAllBytes("./" & "Updater.exe",My.Resources.Updater)
  2. Process.Start("Updater.exe")
Posted in Programming, VB.NET | Leave a comment

Final Fantasy XI Configurator v1.1

FFXIConfig

ChangeLog
-Added some new options
-MIP Mapping
-Environmental Animation
-Bump Mapping
-Font Quality
-Skip Intro Movie

Download

Posted in Final Fantasy Configurator, General | Leave a comment

Taskmanager Plus FileRemoval Update

This was a feature I have been planning for some time and finally got around to working on it. Basically it will have default folders that will be in the program. These folders will be where your temp files are located. All you would have to do from here is click the clean button next to the item and it will remove those files.

You are also able to add your own folders that you wish to be included in the program. So anytime you start up the application you will get the list of folders and the amount of space they are taking up.

The design in the video isn’t what I plan on having it look like on release but it’s functionality will be the same.

Posted in TaskManager | Leave a comment

Taskmanager Plus Update v 1.0.1

taskmanager
Version 1.0.1

-Added the ability to stop multiple processes at once. Simple control click the ones you want to stop and click End process.
-Forms have changed, new features will be added that deal with clean up on temp files and fixing other policies within windows

If you have the program already simply click file and check for updates. It will say an update was found click yes and then in the new windows click update. Or go to the download link in this post
Download

Posted in TaskManager | Leave a comment

FileName Cleaner


Filenamecleaner

Download

Often times I edit files and I end up with files with (1) appended to the file name. This can get pretty annoying to have to go back and clean that up. Well that’s no longer a problem now that I solved with with an easy to use program that does the work for you.

Posted in General | Leave a comment

Hardware Profiler

This was something that I started maybe last year and well with work and other things I haven’t been able to really put work into it. As of now I finally got the windows portion of the program done and all that needs to be done is the web part.

The image below isn’t what the final product would look like, I just wanted to get it functional.

Posted in General | Leave a comment