Categories
Geeky/Programming

HowTo: Make a Win32 DLL without MFC and ATL

Vs2005->New->Project

Win32->Win32 Project

On the Wizard, Application Settings, choose DLL radio box, hit finish.

This is all great, except when you build it, you just end up with a dll. How do you use the dll in another project?

Add a Module-Definition File (.def) – call it Export.def

next time you build, there will be a “.lib” file avail so you can link in the dll with another project.

You can add a EXPORTS section to export functions. The LIBRARY secion is added for you automatically. Have Fun with your new Win32 dll!

Categories
Geeky/Programming

SSRS, SSAS – Auto Pick Yesterday

If you ever have written any Reporting Services reports off a cube (Analysis Services), and want to have a drop down that auto picks a day, this is for you. There is probably a more elegant way to do this, but it works.

=”[Time].[Calendar Date].&[“& Year(DateAdd(“D”,-1,DateTime.Now())) &”-“& IIf(Len(Month(DateAdd(“D”,-1,DateTime.Now()))) < 2,Month(DateAdd("D",-1,DateTime.Now())),"0"&Month(DateAdd("D",-1,DateTime.Now()))) &"-"& IIf(Len(Day(DateAdd("D",-1,DateTime.Now()))) < 2,"0"&Day(DateAdd("D",-1,DateTime.Now())),Day(DateAdd("D",-1,DateTime.Now()))) &"T00:00:00]"

Remember, months and days need to have a zero in the front of them.

Categories
Geeky/Programming

What's A GUID?

GUID – “GooID – not Gee You ID” – a unique identifier. There is often debate on the uniqueness of GUID’s. Microsoft uses them for a ton of things. CLSID’s in the registry, uniqueidentifer fields in SQL, and just anything unique. Microsoft isn’t the only one to use them, Oracle, Novell, etc use them.

As far as the uniqueness of GUID’s, here is what I found on Wikipedia:

“While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.40282366×1038) is so large that the probability of the same number being generated twice is very small. For an application using 10 billion random GUIDs, the probability of one or more overlaps is on the order of 1 in a quintillion.”

A quintillion is 1018

That is alot 🙂 since scientists estimate that there are about 70 sextillion stars in the sky, lets just say that the number of GUIDs is close to a duodecillion – which is more than the sextillion (if I have my large number names correct)

Those numbers alone should end any debate on duplicate GUID’s occurring in the wild, unless you are doing something really wacky to generate them. Some say that because in V1 of the algorithm, the MAC address was used as a basis for the last 4 digits, that you could get duplicates. I think that is still hard to believe that you would get dupes, since it was just the last 4 digits and it just didn’t use MAC address, it also uses time. So two computers with the same MAC address would have to create a GUID at the same nano-second. And even if that did happen, it would have to be a GUID used in the same application to have any adverse effects.

One problem with GUID’s, which usually happens because of sample code on the net, is that people use the sample code that has a GUID hard coded, and then reuse it in their application, which then can end up with duplicates on user’s computers. Browser Helper Objects, Explorer Shell Hooks, etc use GUID’s. Any DLL you want to register (COM for instance) is going to create a GUID when registered. It is always a good idea to create a new GUID when deploying any code that would use it. Visual Studio has a utility built right in on the tools menu to create GUID’s for you.

Basically, every developer should know what GUID’s are, and how they can be used, and how to created them. It is something that you should be able to talk about with colleagues and have no questions on the creation, use or uniqueness, or how to pronounce it 🙂

Categories
Geeky/Programming

VS2005 MFC Class Wizard Changes

If you ever used Visual Studio/C++ 6 (98), you would notice that the MFC Class Wizard allows you to set up messages as you create a class. Well, I’m not sure about VS2003, but VS2005, when you use the MFC Class Wizard, there are no options for setting up messages and events. Where did the options go?!?! Well, if you click on the class in class view, there are more little buttons on the properties window. If you click on the little icon next to the lightening bolt, you will see you can then set up messages for your class. Easy as 1-2-3!

Categories
Geeky/Programming

Vista Bug – Filename to Long

So, tonight I was cleaning up my hard drive, and windows.old folder from the Vista upgrade was sitting there, 25 GB. So I decide to delete, and it removes everything but one file. The file won’t delete because it says the path is too long. I cant rename it or move it because the path is too long. I had to open cmd prompt and CD to that directory and delete the file using the command line. What a debacle 🙂

Categories
Geeky/Programming

Ajax Impressions

Today I played around with doing some ASP.NET web forms in AJAX. Using Anthem.Net. First I’d have to say, Anthem is pretty easy to get started with, but their could be some better examples. One thing I found is that If you have to call some server side code from javascript and vice versa, it cant get a little tricky. I think for now for what I’m working on I will just stick to a non-AJAX route. It seems that with the way I have it in AJAX, you cant hit a button or cause an event to fire until the whole site is fully loaded, which maybe I have something wacked, but it isn’t going to work. I’ll probably dig more into it though.

Categories
Geeky/Programming

Microsoft Office 2007 Keys are on MSDN

Just noticed that the keys for Office 2007 are on MSDN, which is cool because that means the ISO’s for the final version will be on there soon. Can’t wait for that, and Vista. Its like geek xmas time 🙂

Update: Office 2007 is now on MSDN, I am downloading it now!!!

Categories
Geeky/Programming

IE7 – Adding Default Search Provider Through the Windows Registry

So, IE7 – cool right, new search bar and everything. And you can go here and add new search providers. You can also use what Microsoft gives you and do it this way. But alas, what if you want to add it without user intervention? Remotely over a network maybe? Or you just want to do it programatically the way any good geek would. You hit up the registry of course!

1. Create a GUID – use vs2003 or vs2005, or something
example = {AC854C16-CA1E-43f1-8513-0D2F36C726ED}

2. create a reg file

3. edit contents of reg file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerSearchScopes]
“DefaultScope”=”{AC854C16-CA1E-43f1-8513-0D2F36C726ED}”

[HKEY_CURRENT_USERSoftwareMicrosoftInternet ExplorerSearchScopes{AC854C16-CA1E-43f1-8513-0D2F36C726ED}]
“DisplayName”=”What you Want as a Display Name”
“URL”=”http://yoursearchurl?params={searchTerms}”

4. run it 🙂

Categories
Geeky/Programming

Do You Know How To Drive?

Yeah, I know how to drive. But do you know what the lights mean? What the signs say? Big difference. You really should ask the question, Do you know how to drive and all the laws that go along with driving.

Do you know how to program? Yes I know how to program. Do you know all the laws 🙂 – well not laws, but the differences of each language Do you know if, then, end if? While, Do While, Dim x as Int, string s; pInfo->Blah Blah etc?

If you know the basics of programming, you shouldn’t have to worry about the what language you are writing. Just like if you know how to drive, you shouldnt worry about the signs, because you can read them as you go, figure them out on the fly.

I see to many students get hung up on the fact that they just learned C++, Java, or vb.net. First, if you know vb.net like a rockstar, you know C# (or is id D flat?)

If you know C++. or C – then you should be able to learn or know Java and C# easily. With that syntax, you should be able to pick up javascript easily too.

VbScript? – you know VB6, VB.net. And like I said – VB.net – you know C#, so it comes full circle. You’re money 🙂
And if you know .NET – create a website and you start learning ASP.NET – which isnt a language as so many people think, but a paradigm – you can use C# or VB.NET to code – so don’t worry.

I started of with C++, then JAVA, then VbScript, VB6, throw in some wacky stuff, Batch files, KixStart scripting, Javascript, then VB.NET – and then C#. There is alot of other stuff that I really don’t know, COBOL, Python, whatever. But you can learn if you need to. If you want to get started with programming – start with Batch Files and VBScript. Look up WMI. Just do anything you can with scripting – it will just broaden your knowledge into the OS and Windows in general.
You also can’t forget SQL. Any programmer should know at least basic SQL – SELECT, INSERT, UPDATE, DELETE, etc. Without SQL, coding data aware applications is pretty tough.

I can’t say I’m an expert, or even close to one, in any of these languages, but I know enough to get me by, and if you know how to ask the right questions, then you can figure out what you need to know to complete your toolbelt of programming.
To really complete your toolbelt – Take a blank computer – setup Windows, IIS, ASP.NET, Visual Studio 2003, 2005, SQL 2005, etc. Its almost like a mechanic. Do you think mechanics don’t know how to get their tools in order? The machine, and the software you use are your tools. You should know them in and out. (Ex: My rachet is squeaky when I use a 1/2 socket). Things won’t always be set up for you. You need to know how to set up your tools! If you are a guitar player – you need to know how to tune your guitar. How else can you play anything good?
So, do you know how to drive?

Categories
Geeky/Programming

Hacking Wifi – Analogies

Well, if you have ever had to “borrow” someone elses wifi connection – here is what I was thinking about today. 1st, there have been cases where people get prosecuted for hacking others wifi. Here are my thoughts on why I dont think it is stealing.

1) If someone has their sprinkler on in their yard and it happens to spray onto the street partially, and you are on the street, and fill up a bucket with water, is it stealing?

2) Your neighbor has a huge picture window, and a huge TV. You live close by. You can watch TV through the picture window just fine. Is this stealing?

3) Back to the sprinkler – what if your neighbor’s sprinkler hits your yard a bit – stealing?

4) Where is the line drawn? If it is a windy day and your neighbor’s leaves from their tree blow in your yard, who should rake them?

5) It is to easy to secure. Don’t broadcast your SSID, turn on MAC address filtering, Using WEP/Tkip, etc. If you do all of these things, and then someone gets your connection – well then it is probably is serious hacking going on, and might be considered a crime.

6) If you have your stereo on and I can hear the CD you are playing – should I have to pay for the CD? phhhh

The bottom line is, people need to be responsible for the technology they own. Just like the guy who needs to be responsible for his sprinkler, TV, radio. Be responsible, take 2 minutes to read up how to secure your wifi router. If not, then expect your connection to be used. 🙂