Web development by PHP-Web-Host.com   Website Hosting by PHP-Web-Host.com
Web Hosting by PHP-Web-Host.com

SoftSmart Blogs!

SoftSmart Technical, Software and Web Related Blogs

Tel (Lon, UK): 020 8133 3460

 

 

Blogs

Archive for the ‘Software’ Category

Bypassing DVD Region Encoding

Monday, April 26th, 2010

I have a growing DVD collection, and this consists mostly of series, or related movies, eg, I have most of “The Sopranos”, “Friends”, “Godfather” and other related mobster films.

So, because my DVD’s are mostly series or related, I prefer to burn the original disc to my laptop. That way I can watch it where ever, when ever.

Here is what I do:

1) I burn the DVD to an iso image on my hard drive using DVD Shrink. DVD Shrink is an open source package that rips DVD’s to iso images and supposedly shrinks them too. I say supposedly because the resultant file is still just under 5Gb. In any case, it does a brilliant job of this!

2) I use VideoLan to watch the iso image as if it were a DVD in the drive. VideoLan is maybe one of the best media players I have ever come across. Its simply brilliant. It is also free, open source. This will play movies and mp3′s equally well.

Ok, so that’s all simple enough, but I ran into a problem the other day. A while back I bought the BBC’s Planet Earth series, but I bought it from the USA, so the region encoding on my DVD player is different to the regional encoding on these discs. DVD Shrink was unable to read the disc because of the DVD Region Encoding. VideoLan on the other hand had no problem playing the disc, they seem to automatically bypass the DVD region encoding. This was pretty cool and I was really impressed once again with VLan, but not surprised.

The problem here is that I don’t want to carry my disc’s with me every where I go. Besides being bulky, they’re also expensive. I read about the regional encoding schemes and I was led to believe that there was probably not a great deal I could do. BUT, this did not deter me and I let logic prevail. Logic dictated that the encoding (or rather the result of the encoding) was not purely at the hardware level. There had to be a software level involved, because if it was purely a hardware issue, then not even Vlan would have worked.

After searching around for some time (and even trying to check the registry for the DVD Region Encoding), I came upon DVD Decrypter.  DVD Decrypter allowed me to bypass the region encoding of the DVD’s and rip them to my hard drive as an iso image.

Now, I am able to once again use VideoLAN to watch my DVD’s straight off my laptop.

Next, I will test what happens when I burn those iso images to DVD. Will it have the same encoding as the original disc, or will it be encoding free? Don’t know yet, but watch this space

 


 

Compiling a C++ dll with MinGW to use with Visual Basic

Tuesday, February 16th, 2010

Using a dll compiled with C++ in visual basic is really rather easy, its just a little hard to find good (EASY) information of how to do it. There is a fair amount of information for Microsoft’s C++ compilers, but what about us who write in a text editor and compile with g++ on MinGW? This post will show you how you can be using a c++ dll in visual basic.

I’m a big fan of ANSI C++, MinGW and the g++ compiler. I don’t like MS C++ compilers for various reasons. One of those is that I don’t believe it generates ANSI compliant code, and I certainly can’t compile for Linux from it.

If you are a visual basic (VB) coder, it may be necessary at times to use a dll compiled in C++. Or, you may be in a similar situation to myself: all of your projects are written in VB and you are porting everything over to C++. However, you have a problem. Porting everything at once will take a long time. If you port a module to C++, you would want to start using that module straight away with your existing VB projects (until you have ported the whole lot).

So, here is a quick guide on accomplishing that. This guide is very simple and is intended to get you started in the right direction.

Create a cpp file called “test.cpp”. In this file, paste the following code:

// Start of file

extern “C” // only required if using g++
{

__declspec (dllexport) int __stdcall FooBar (void)
{
return 343;
}

__declspec (dllexport) int __stdcall TimesTwo (int val)
{
return val * 2;
}

}

// end of file

Now we need to compile our dll. There are two steps (maybe they can be converted into a single step, but as I said, this is a beginners guide and I’m not an expert (yet) on the g++ compiler).

To compile, in MinGW, cd to the directory that has your cpp file and type:

g++ -c -Dtest_dll test.cpp

This will create a file called test.o

Now type

g++ -shared -o test.dll test.o -Wl,–add-stdcall-alias

This will create test.dll

Now, open a normal VB  project and in the form’s code space, paste the following

Option Explicit

Private Declare Function FooBar Lib “C:\msys\1.0\home\John\Dll_with_VB_test\test.dll” () As Integer
Private Declare Function TimesTwo Lib “C:\msys\1.0\home\John\Dll_with_VB_test\test.dll” (ByVal val As Integer) As Integer

Private Sub Form_Load()

Debug.Print FooBar

Debug.Print TimesTwo(5)

End Sub

Take note of two things here:

1) The path to the dll must obviously be changed to be correct on your system

2) In the second declare, we pass an integer called val in to the dll. If you leave out the ByVal, the value is corrupted, so the ByVal bit is important.

That’s it, please post back here if you have any useful insights. Lets learn (and port our software) together!

 


 

Starting Windows Services in VB

Saturday, January 16th, 2010

At times it may be necessary for you to control windows services in your visual basic code. For instance, one of the applications I had written used various software modules to write to and read from a MySQL database. I then used IIS to connect to the database and display reports to users on the network in a web browser.

The problem came in when MySQL version 4 must have had a little bug, and it did not work very well with IIS. When there was a relatively large amount of data in the recordset, MySQL would fall over with the annoying little message: “MySQL has gone away”. Later on, when version 5 became available, I installed that and it solved my problems, BUT in the interim I had a problem. I couldn’t tell my clients to wait around for newer versions of MySQL, and I also didn’t want to rewrite components to use another database.

So, the solution was to trap the errors that MySQL crashes generated and automatically restart MySQL as a windows service. This could be any service though, I just happened to use it for MySQL.

If you go to control panel –> administrative tools –> Services, you will see a list of services there with their service names. Use this name with the code in the download below to stop, start or pause your windows services. I am not going to give a detailed description of every line of code (because honestly I don’t really know most of it, its alot of API calls!). Instead, by supplying the source code, I hope that you will be able to modify this and use it in your own code.

Restarting Windows Services with Visual Basic Start windows services in VB

 


 

Visual Basic Chess Game

Thursday, January 14th, 2010

This source code for a chess game written in visual basic is another tutorial that is dumped into the intermediate category, however, I think it could really fit into the beginner and advanced categories too. The reason for this is that there aren’t really any advanced things going on here in terms of strict visual basic code, but the logic may be a little tough, especially as this was one of my early projects, so in some cases the naming conventions suck, ie, are really non existent, and some things are just done the long way round. However, having said that, it still works and that’s pretty cool.

This is not a tutorial in the sense that I am going to ramble on here about writing a chess game in visual basic. This is rather another tutorial where I say, here is the source code, step though it and see what you like, see what you don’t, see where you can improve, but learn from each of those steps. There really is just too much in the project to talk about here.

I will just mention a few things:

1) One of the things to learn from this code is drag and drop. This visual basic chess game uses drag and drop to drag chess pieces around the board and drop them into the square they are moving to. This is a little trickier than it may sound at first because often times the piece is not dragged and dropped cleanly into a single square. It may be 90% in a square, but not exactly. You will see that there is a little calculation that goes on to determine which square it was dropped into “the most”.

2) Many routines simplify logic. I think that I probably could have even created more routines to simplify even further. Now I am not talking about arbitarily adding routines, I am talking about drawing a flow diagram with pen and paper (remember those??), and then coding the flow diagram. By making each routine as small as possible, ie, one job per routine, you simplify your logic because at a high level, you get code that looks like this:

private sub MovePiece()
IsThisAValidMove()
MovePieceToLocation(x,y)
IsPlayerInCheck()
HasPieceTakenOpponent()
End Sub

This is NOT actual code from my source, but it illustrates the type of things I was trying to achieve (as I mentioned before, this was one of my first, so I might not have succeeded entirely).

3) Move highlighting. Because of the modular style of writing this software as described in the point above, it was very easy for me to add “move highlighting”. For the colour whose turn it is to move, right-click on any piece, and it highlights all the possible moves that piece can make at that time, so this could potentially help someone to learn the game.

4) There is no AI in this game yet. This game currently requires 2 people to play. There has not been any effort yet to add artificial intelligence for a computer player.

PLEASE, IF YOU START THE PROCESS OF ADDING AI TO THIS GAME, I’D LOVE TO SEE IT.

If you use this code as the start of your own project (with or without AI), PLEASE send it back to me. I will NEVER ask you for anything, ie, I don’t want your money, I don’t want royalties, I don’t even want acknowledgement in your product (although it would be nice). ALL I want is just to see where this code is going, and please, if you find this useful, please tweet about it @softsmart!

Anyway, having said that, please download the code and happy coding / gaming….

Visual Basic Chess Game Source Code –

 


 

Converting Links in a text file to anchor tags usable in your website

Saturday, January 9th, 2010

I recently answered a question about converting links in a text file, eg, www.softsmart.co.za to an anchor link that could be used in a website, eg, <a href=”http://www.softsmart.co.za”>http://www.softsmart.co.za</a>.

I decided that since I was such an open source evangelist, the best thing I could do was whip up a little application to do this:

Here is a brief synopsis of what it does (links at the bottom):
It takes a text file that has one link per line.

You can start the program in several ways (its a console program):
1) Just start it and it will ask you to type in the full path and name of the file (unless the file is in the same directory, then name alone should be fine)
2) You can start the program from a dos prompt followed by the name of the file in quotes, eg, c:\>UrlToAnchor.exe “C:\Folder 1\Folder 2\test.txt”
3) Easiest method is open the folder that has this exe, then in a different folder open the folder with your text file, then just drag the text file onto the program.

It will ask you 3 questions. These are related to what you want the resultant anchor text to look like:

1) Do you want a title tag? If ‘y’ then it will place the title=”eee” into the tag, using the domain name as the title
2) Do you want to use the title tag as the link text? If ‘y’ then the title tag is the link text, ie, what the user sees and clicks on
3) Do you want the links to open in a new window? If ‘y’ it adds the target=”_new”. This is nice if you are placing these links on your own site but you don’t want people to go out of your site.

I tested this on a very average machine (my laptop) with a file that had 200 000 dummy links. It ran that in just under 2 minutes.

Ok, here is the disclaimer…

1) I am giving this away for free, so there are no guarantees. However, if you need help or you want a feature added, mail me, I’d be more than happy to help. My time is very limited however so you may have to wait.

2) I know that its scary using free software from someone you don’t know, so I’ll make this opensource. You can download the program and run it, or you can download the source and check it out, modify it then compile it yourself. Although I haven’t tested this on Linux yet, I do try to stick to ANSI C++, so this should compile on both (Please post here if you want me to compile a Linux version).

What do I ask in return? If you want to make a comment on the blog, make it nice! If you do download the source and modify it (or post it on your own website), please respect 2 things:

1) Please post back to my blog to let us all benefit from the mods
2) Please keep my title info at the top of the source file (its only one file). You can add yours below!

Click here to download the exe for windows

Click here to download the source file

 


 

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

 

 

We accept PayPal

 

Web Hosting by PHP-Web-Host.com Website Hosting by PHP-Web-Host.com

[ Home ] | [ Software ] | [ Web Development ] | [ Resources ] | [ Contact ] | [ Privacy Policy ] | [ Acceptable Use Policy ] | [ Terms of Service ] | [ Sitemap ] | [ Clients ] | [ Affiliates ]

[ PHP Web Hosting ] | [ Linux Web Hosting ] | [ 500mb PHP Web Hosting ] | [ 1Gb PHP Web Hosting ] | [ 3Gb PHP Web Hosting ] | [ 6Gb PHP Web Hosting ] | [ 10Gb PHP Web Hosting ]

[ HTML Tutor ] | [ CSS Tutorial ] |