Saturday, December 20, 2014

DCS 933L Installs and LED Settings

If you need to reset them you need to download the application that configures them, not use the mydlink website.

To disable the blinking LEDs (not 'disable being able to set the LEDs' which is what the name incorrectly implies:

http://forums.dlink.com/index.php?topic=47665.0


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.

Tested in Visual Studio 2012


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");


update:
secure version:

DWORD pid;
pid = GetCurrentProcessId();
AllocConsole();
AttachConsole(pid);
FILE *streamfp = NULL;
freopen_s(&streamfp, "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);  //TODO: wide char memset

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.

Had some issues in a different visual studio project, i think it is related to default project settings. here is a C version that handles the issue:

//
//  PrintKey takes the key, subkey and value as input and prints the value as output
//  it opens the registry, reports the value, and closes the registry when complete
//  Example usage:
// PrintKey(HKEY_LOCAL_MACHINE, "Software\\Intel\\IGFX\\USC", "CSSIMD8CompileForce");
//

void PrintKey(HKEY hkey, LPCTSTR subkey, LPCTSTR valuename )
{
long result;
HKEY hkey_fromRegOpenKey;
DWORD dwType;
wchar_t szVersion[32];
DWORD dwDataSize=sizeof(szVersion);

//it is like a database, you have to first open the registry values you want to query
result = RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &hkey_fromRegOpenKey);
if(result != ERROR_SUCCESS)
{
printf("RegOpenKeyEx failed for %ls\n", subkey);

//std::cout << "RegOpenKeyEx Failed for " << subkey << std::endl ;
}

//next, query for the specific value
wmemset(szVersion,'\0',32);
result = RegQueryValueEx(hkey_fromRegOpenKey, valuename, NULL, &dwType, (LPBYTE)&szVersion, &dwDataSize);
if(result == ERROR_SUCCESS)
{
printf("%ls\t", valuename);
wprintf(L"%d\n", *szVersion);

// OLD VERSION
/*if(result == ERROR_SUCCESS)
{
std::cout << valuename << ":\t"  << *szVersion << std::endl;
}
*/
}
else
{
printf("Error reading %ls does it exist in the registry?\n", valuename);

//std::cout << "Error reading " << valuename << "does it exist in registry?" << std::endl;
}

//finally, close the registry
RegCloseKey(hkey_fromRegOpenKey);

}


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