Tuesday, October 21, 2014

Moving from a console to a windowed app with a windows entry point (winMain with the expected parameters)

often when i start early iterative development on a project i start from a clean sheet and build up as a console application. sometimes i need to make it a real app and need to move from main() to a real windows entry point like this:

int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow )

To do this in a project originally created as a console application go to the property page for the project by right clicking the project, select Configuration Properties->Linker->System, go to the SubSystem editable property, select System->Subsystem dropdown, select /SUBSYSTEM:WINDOWS.

blammo.


Saturday, September 13, 2014

MSVC path for .dlls when you want to put it in your source development tree

When creating projects in MSVC, and assuming you don't want to put the .dll in your system directory but instead local to your project, the default location it will look for a .dll you want it to see is not the top level solution directory but in the respective debug or release directory for the project.  

Monday, August 25, 2014

Attaching a console in Win32

how to get a console in a few simple lines of code in windows:

DWORD pid;
pid = GetCurrentProcessId();
AllocConsole();
AttachConsole(pid);
freopen("CON", "w", stdout);
printf("hello, i am the console\n");

Thursday, May 08, 2014

Using RegOpenKeyEx and RegQueryValueEx

just putting this mess of code here for later cleanup, maybe somebody else finds it useful

assuming you need a REG_DWORD, if you need another type, REG_SZ for example, you will need to tweak this slightly.

if you have used this:

 int result;
HKEY hkey = HKEY_LOCAL_MACHINE;
HKEY hkey_fromRegOpenKey ;

result = RegOpenKeyEx(hkey, TEXT("my\\fav\\subkey\\location"), 0, KEY_READ, &hkey_fromRegOpenKey);
if(result != ERROR_SUCCESS)
{
             printf("FAIL\n");
}

  DWORD dwType;
  wchar_t szVersion[32];
  DWORD dwDataSize=sizeof(szVersion);
  memset(szVersion,'\0',32);

result = RegQueryValueEx(hkey_fromRegOpenKey, "myval", NULL, &dwType, (LPBYTE)&szVersion, &dwDataSize);

You can use this to print it in C (TODO: simplify the dwValue casting mess from cpluscplus):
//extract a dword from a binary buffer
DWORD dwValue = 0;
dwValue = *((DWORD* )&szVersion); //C cast for brevity as suggested at: http://www.cplusplus.com/forum/windows/109826/
//dword is an unsigned int
printf("%u is dwValue\n", dwValue);

just putting this here so i don't lose it.


Thursday, April 03, 2014

Correct directory structure for clang and llvm 3.3 source tree when using cmake

instructions are slightly outdated.

download clang
download llvm

after unzipping clang go into the clang directory and grab the cfe-3.3.source directory and put this into the tools directory under llvm before running cmake.



Wednesday, February 12, 2014

Trying to find old versions of the Java SDK?

Trying to build the Android OS from Source and can't find the required version of Java?

Go here:

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html

Thanks to Aaron Kunze for the tip.

Here's the quote from the Android SDK build website under 'Setting up a Linux Build Environment':

JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both fromjava.sun.com




Thursday, May 30, 2013

Travels to Nyon, Switzerland and the Italian Alps

Image from Cogne, Italy:
 Cogne, in the Italian Alps:
 Stacey trying some milk out of a vending machine on a farm in Switzerland!
 A field on the outskirts of Nyon, Switzerland
 A seafood feast held on Sundays in Devon, France. We had some delicious crab and shirmp. Super fresh and fun times.

We went to a fondue place in the mountains around Nyon, Switzerland:



Travels to Cinque Terra, Genoa, Barolo, Milan

 
Cinque Terra, a view from our hotel room in Vernazza.
After finishing a hike on one of the lower trails, we get to the end to find a 'trail closed' sign. Might have been good to post this at the beginning of the trail on both sides, was admittedly a fairly treacherous walk.
On a short hike into the Italian Alps near Aosta we came across this giant tunnel thing.
A view of the town of Vernazza from the lower trail between Vernazza and Monterroso:
A view of the town of Corniglia:
Vineryards around Barolo:
Another view of the vineyards:
Panorama, more vineyard.
Finish your day with some water, only 59 Euros.
Kidding, if that isn't good enough there is some for 250 Euros (>$350 USD)

Was walking around Milan and came across the Duomo, amazing architecture.

Monday, May 13, 2013

Travels to Prague, Czech Republic



Prague was impressive. It is another European city with lots of old buildings, etc. Reminded me a bit of Barcelona. A welcome small town feel relative to the largeness of Budapest. Prague had a smaller core and we spent a good bit of time just wandering around into various artisan shops. Also took a Segway tour of the hills of the city which was our first time on a Segway, very fun! It took about 5 minutes of training and we had a great time.


Our hotel was in the area called XXX and was centrally located just near the Charles bridge. I discovered XX served at the local foodie restaurant/bar called Lokal. There were two locations. Essentially this was the freshest beer one can get and I got to try Pilsner Urquell served this way. It was very fresh and had a soft, smooth taste.  Generally Pilsner Urquell in the US is served out of a bottle and is in the normal bitter/bad beer category, nothing special or unspecial, just a bottle of average yuck with increasing levels of awfulness as it attains room temperature. Served this way it was fantastic and highly recommended. 


apparently there is a budweiser in the czech republic that is not the budweiser in the US. yes, i tried it. It is not the same.



an image from a coffee shop in prague...choco cafe:

from our segway tour:

an image by the astronomer's clock:
Tank beer, much improved taste...is this what real Pilsner Urquell tastes like?

Travels to Budapest, Hungary


Spent a few days visiting the historic city of Budapest. The feeling here is a large European capital. We stayed on castle hill. Toured the parliament which was remarkable. Walked the hill to the Chain bridge multiple times. Lots of history. One highlight was a non-tourist wine tasting in a several hundred year old wine cellar. Only disappointment was we were a little time constrained due to a previous engagement. Also had some excellent dumplings filled with chicken. In most cases, ‘dumplings’ were really just very small doughballs. Was surprised to find many dishes flavored with a delicious paprika which is a red spice. Another favorite was ‘goulash’ which was a stew of meat, potatoes , some other veggies and generous use of paprika in the sauce.

a latte from a fancy coffee shop:


statue of bridge and guy near the parliament building:

our rental car...just kidding

some statues....

this is the part of the castle wall in budapest that was defended by the fisherman centuries ago. rebuilt and now a bar/tourist attraction.
 it is anonymous!


a coke, potato chips, and a donut value meal. oh, and pizza! not only in america!
 castle in budapest:

famous statue

ronald reagan statue, next to the controversial (and last) communist monument standing in city of budapest.


bioshock like font
 mcdonalds ketchup in the grocery store!

several hundred year old wine cellar located under the hilton hotel by a few hundred meters!

a very old espresso machine
 a very new espresso bar. needs fresher beans.


 a late night gelato run with the khronos klub: