RegistryKey.GetValue() returns null on existing values

I encountered a very curious issue today, as a user of one of my tools complained that the tool was crashing because of an access to an uninitialized field. Because of the error reporting system in all my tools that gives the user the stack trace to pass on to me, I saw that the line that was causing the crash was a GetValue() on a registry key and value, that the user insisted existed. So, looking around StackOverflow, I noticed that if you compile to x86, you may have issues accessing some keys and values in the registry, because Windows may give you the wrong Registry view by default (I guess Windows gives a different view to 32-bit applications that the one it gives to 64-bit ones). I was accessing the keys by using OpenSubKey() on Registry.CurrentUser, but I guess that gives me whatever registry view Windows wants to give me.

So, given that there’s two RegistryViews, I thought I should change my GetRegistrySetting() and SetRegistrySetting() code to try both. Once I did, the problem was gone. Read on for the code that is part of my LeftosCommonLibrary set of tools, or just view the file that contains the code below in GitHub.

Continue reading

Downloading/Editing/Compiling an Open-Source App (Visual Studio, Git)

Downloading/Editing/Compiling an Open-Source App (Visual Studio, Git)

So, I see that my blog is the one place I forgot to announced that I’ve accepted the position of Software Engineer at 2K Sports to work with the NBA 2K team. Oh well. So, yeah, that’s pretty much it. Expect more about that soon. (I’m really excited about it, magnitudes more than this first paragraph shows, but this is not exactly the reason for this post.)

However, not everyone took that too well. There’s a lot of people using the tools I created for NBA 2K12 and 2K13, and they’re disappointed to see me go and stop developing game-specific tools (other tools like NBA Stats Tracker and Hex on Steroids I’ll still work on as a hobby whenever time allows). However, since all my work is open-source, there’s nothing stopping you, any of you, to grab the source code, edit it to your heart’s content, compile and re-release. There’s even a project that I know people were waiting for, namely Roster Workshop, which was to be 2K13’s equivalent of last year’s Roster Merge & Repair, improved and with a whole lot of new features, that never got released with how things turned out. Still, nothing stopping you from releasing it and keeping on working on it. Any of my tools.

Continue reading

NBA Stats Tracker: Play By Play Tracking

Absolutely BIG things are coming for NBA Stats Tracker (i.e. my thesis which I haven’t stopped working on even after turning it in).

v1.13 has just been released!

Version 1.13 introduces the Play By Play Editor! You can now insert play by play information for any of the games you keep track of. This is merely a preview of a series of upcoming features, including calculating the box score based on the play by play information, and using that information to do analysis such as partial stats calculations. Soon, queries such as “How well does Player X shoot between 10 and 16 feet when guarded by Player Y and when there’s less than 8 seconds on the clock?”, or “What happens when Player X and Player Y are on the floor together in the 4th quarter?” will be doable, providing an unparalleled level of analysis.

Image

The Play By Play Editor interface

To find out more about NBA Stats Tracker, visit its official thread in the NLSC Forum.

 

Out of ideas? Not out of things to do (to improve your code)!

Out of ideas? Not out of things to do (to improve your code)!

This will seem like the most obvious tip ever, but I thought I’d get it out there for those that may have forgotten about it in a while. If you’ve ran out of ideas on what to work on  your project next (i.e. you have no new features or improvements in mind), try going through your codebase and find the oldest pieces of it. (Side note: Having your codebase be in something like a Git repository that can tell you when each line of code was committed and thus last edited can be amazingly helpful.) Chances are you’ve grown since then. You’re a better developer. You have more tricks up your sleeve. Maybe you know of a new algorithm, a new library, a new, better way to do things. Maybe you’ve read about security risks you weren’t aware of. There’s almost definitely going to be something there that could use some tidying up, some improvement.

Look for redundancies, variables or parameters that seemed helpful at the time, but now seem obviously unneeded. Look for opportunities to refactor, to optimize, to parallelize. Look for possible security risks, replace unsafe procedures and methods with safer ones. Maybe try doing a whole piece of code from scratch.

Continue reading

Your Command Line needs more TREEs

I have no idea why I’m so excited about this. No idea whatsoever. Really. It’s not a useful tip. It’s more that I feel like the 23-year-old that I am suddenly discovering a notebook that has been under his bed since he was 5, only to open it to realize that Page 1 has a shopping list of his mom from 1995, and the rest is empty. It’s that kind of excitement.

So, while watching user RogueAmp on YouTube today, specifically the video where he calls a fake Tech Support Company that tries to persuade you your system is full of viruses and that you should play them sums upwards of $99.99, I realized this amazing thing:

The Windows Command Line native command-set has a program called “tree”! And what does tree do? It displays the current drive’s contents AS A TREE (boom!) with nice ASCII art to match.

The tree command in action.

Beauty beyond words.

No need for Windows Explorer. We have tree now. My life is complete.

P.S. Mental note: Do not drink that much coffee in one day.

P.S.2 Do visit rogueamp’s channel. I love his videos and how he tries to tackle malware left and right, adding his fun personality to the mix.

Fix for “Automation Server Can’t Create Object” (Updated)

Updated to include sample .REG file of solution. Read on.

I love foobar2000. I absolutely love it. It’s lightweight, straight-forward, and so customizable it’s ridiculous. I loved it even more when I found out spotifoo (a skin for foobar2000), which although now a couple of years old, does everything I want (including Last.fm scrobbling, play count and love) and still has a very uncluttered and space-effective interface. However, recently, and with no indication as to what caused this change, when I started up foobar, most of the panels of the spotifoo skin were replaced by an “Aw, crashed! :(” message, and I was getting multiple errors about an unexpected script issue. I checked the console, and it was full of “Automation Server Can’t Create Object” errors. I have been trying to find a solution for this for weeks, I even switched to MusicBee for a while; but I HAD to get my foobar2000 back. Finally, I’ve just found the solution, but it’s in no way an elegant one.

Continue reading

Going from C# to C++ in preparation of …”something”

After a few years of developing only in C# (all my hobby projects, e.g. modding tools, as well as my thesis, were written in C#, targeting .NET 4 and using WPF for the pretty (the what?) UI), I’m “back” to C++. To be brutally honest, I haven’t used C++ much. I did use it for whatever university assignments I had that required it, and I learned some pretty basic and important concepts with it, such as server-client architecture, multi-threading, message passing, parallelism. Only reason I didn’t get into it more was because when I did decide to get in trouble and start developing on a daily basis on projects I loved, I had already discovered C#. C# promised the power of C++, with a minimal amount of the trouble that C++ could cause you. Its power, the level of automation and abstraction the .NET platform offered, and how well tied it was with Visual Studio made it an absolute pleasure of a language to develop in. I could do everything I wanted, I had Visual Studio’s magnificent visual debugger, IntelliSense, documentation, I had LINQ; you could say the world was my oyster. And I created some useful things with it. All my modding tools were put to use by the basketball modding community, and NBA Stats Tracker was even used by a varsity basketball team in the US. I learned a whole fucking lot from using C#. My first big project, the delicateness of code where a single, innocent-looking change can break so many things in the rest of your project, trying to refactor and messing things up, trying to find what went wrong in a stack trace that was 9 calls deep, how to properly design an object-oriented program, what to do when you manage to crash the CLR (yes, that actually happened), so many things that I simply cannot list of the top of my head, really.

But C# is a world of convenience. 50% of what you need to do, it’s there, in the libraries. Memory allocation? Done for you. You declare and allocate everything the same way, not having to worry if something won’t fit in the stack, not having to worry about dangling references, segmentation faults, undefined variables.

Enter C++.

Continue reading