Thursday, December 30, 2004

Settling in

Ah, to end from that wearisome nomadic feeling. What a trip. I'm here in my new office, coffee brewing in the kitchen, cable running up the hall from my bedroom to said office so that my cable modem can connect. Why?
Well, after 4 visits, a signed letter from my landlord, and me finally taking a hammer drill to the wall, I still don't have a jack in the wall of my office. I can't go into the cable company's lock box, and they can't do it without a work order. Oh the red tape.
How about the move itself? Well, Friday was an adventure of stairs and stacking... won't go any more into that. Saturday, got started 45 minutes later than we wanted, but ended up down here 4 hours later. Multiple stops to tie down the tarp on my fathers truck in a fruitless effort. Plus one 2 1/2 hour diversion in Lords Valley PA, to replace the tire on the moving truck.
A nice big spike, screw with a hex head, got lodged in the front right tire. Happily, there was a guy 1/2 mile down the road, who was in doing paperwork on Christmas day. He owns a scrapyard (with 38 cats) and happened to have a Ryder truck the same size as our Budget truck. Tires and rims were a match so after digging around for a hand jack, hiking into the far reaches of his property, and jacking the truck up, we had our wheel. Oh, $160 dollors were thrown in there too.
Was it all worth it? Well, this place is twice (literally) as big as our last place, it's first floor, I have a good sized office with a door, we have plenty of room, and it's quiet. I like it here. We both do, so we think we're gonna stay. And best of all, I've got Twizzlers!

Friday, December 24, 2004

One more thing

I guess I forgot to post it, in all the hustle and the bustle. I finished the project, or at least the portion I needed to. I was able to handle events from the Kodak 14n and copy the file to the hard drive. Now adays, everything is WIA, TWAIN, or mass storage device. Kodak makes it hard. Oh well, it works. I have to wrap up some stuff, and then incorporate it into Data.Match, but I'm glad it's done. Check out this long Channel9 post.

The trucks loaded!!!

Today, Friday the 24th we loaded the truck. Other than having my bro almost drop a couch on me, we're doing ok. We cleaned the apartment, went out to eat with my folks, and tomorrow we'll all head down to PA.
I'm blogging from my parents where my wife and I will be staying. Boy I'm tired. Got a 6 hour drive, and unloading. At least it's 1st floor, not 2nd like the one we emptied today. Guess I should check my e-mail.

Wednesday, December 22, 2004

It's almost done

I'm sure many people can't wait for me to pack up and move to PA, specifically those on the forums I've been harassing. But my project is almost done. My code recieves events from the unmanaged code, once. After that, the unmanaged code seems to hang. However, when my code closes and get's GC'd, I get errors from the unmanaged code that it can't "Read" from memory. One error message for every event that should have fired.

On the lighter side, I thought I'd post something for all those who think it's wise to teach your kids to lie from an early age. 'It's only a little lie.'

Christmas Trivia
1. The average American takes six months to pay off holiday credit-card bills.

2. What is Pogonophobia: The fear of beards.

3. There are currently 78 people named S. Claus living in the U.S. -- and one Kriss Kringle. (But many Krispe Kremes)

4. December is the most popular month for nose jobs.

5. Weight of Santa's sleigh loaded with one Beanie Baby for every kid on earth: 333,333 tons.

6. Number of reindeer required to pull a 333,333-ton sleigh: 214,206 -- plus Rudolph.

7. Average wage of a mall Santa: $11 an hour. With real beard: $20.

8. To deliver his gifts in one night, Santa would have to make 822.6 visits per second, sleighing at 3,000 times the speed of sound. At that speed, Santa and his reindeer would burst into flame instantaneously.

Tuesday, December 21, 2004

I am panicing!!! I need to resolve this.

This is the last step I need to complete before I leave. I just need to catch the events. Now I don't get an exception, but I know the events have to be firing. Why doesn't the unmanaged code fire my code!!! Am I passing the wrong thing?!?! Help please!

Check out the details here.

I need help!!!

I'm posting everything I've got for this project. Here's the link. Please, please, please, I have one last part, and 2 days to do it.

You can look at the last post on this blog to see what I'm having problems with.

Monday, December 20, 2004

I can read pictures through the proprietary software!

I finally got images off this stupid Kodak camera. Only 1 task left, but I'll let you see what I've done so far.

'Get a handle to the directory
myStatus = Me.KAllocDirItemByPath(myCameraRef, myFolder, myDir)

'Allocate a direcotry iterator for that folder
If myStatus = 0 Then myStatus = Me.KAllocDirectoryIter(myDir, myDirIter)

'Iterate to the next directory item
myStatus = Me.KIteratorNext(myDirIter, myDirItem)

Do Until myStatus <> 0

I set it up this way. You have to get a handle to directory, passing in a string for the path name. (ie. "Camera\Card1\DCIM\FolderName\")

Then you get an iterator, and walk the iterator for the different files.

In my loop I have this code:
'Create a handle to the source file
myStatus = Me.KAllocIORef(myDirItem, mySrcIO)

'Create the handle to the file. The handle is a fileStream(fStream).handle
fStream = New IO.FileStream(memPath.ToString, IO.FileMode.Create)

'Create a handle to the destination
myStatus = Me.KAllocIORefFromFileHandleRef(Me.myLibMgr, fStream.Handle, Me.myTrgIO)

You follow all that? When I get the file as 'myDirItem' (an IntPtr Kodak's software uses to point to the file) I pass it to Kodak to create an IO Reference to the file. I create a file stream (much simplified thanks to .Net) and then pass that to Kodak to get an IO Reference to the stream.

Then I use one more Kodak functions to read from the IO Ref to the file, filling a buffer, then another to write to the IO Ref to the stream. They sure have a lot of functions.

The problem I had had was what to do for a buffer. Mostly when I've written a file, I've read right into the stream, or something similar. I had to create a buffer like so:
Dim theBuffer(524288) As Byte

Now some of you sharp guys will say, 'Hey, files aren't always going to be 500k!' You're right. I did this:
numBlocks = CType(Math.Floor(fileSize / theBuffer.Length), Integer)
finalBlock = fileSize - (numBlocks * 524288)

For blockIndex = 0 To numBlocks - 1
'// Read from the camera's memory
myStatus = Me.KRead(mySrcIO, theBuffer.Length, theBuffer)

'// Write to the host file
myStatus = Me.KWrite(myTrgIO, theBuffer.Length, theBuffer)

'// Read the final block
ReDim theBuffer(finalBlock)
myStatus = Me.KRead(mySrcIO, finalBlock, theBuffer)

I broke the file into 500k chunks, then when I was done with the nice clean chunks, wrote the leftovers.

Now, for any of you who are saying, 'This guy knows his stuff!' or 'This guys an idiot!', I'm simply porting Kodak's demo code for reading/writing files.

One more thing. The unmanaged read/write wraps:
Declare Auto Function KRead Lib "DCSPro4SLR.dll" Alias "KPDCRead" (ByVal inIORef As IntPtr, ByVal inCount As Integer, ByVal outBuffer As Byte()) As Integer

Declare Auto Function KWrite Lib "DCSPro4SLR.dll" Alias "KPDCWrite" (ByVal inIORef As IntPtr, ByVal inCount As Integer, ByVal inBuffer As Byte()) As Integer

You've got to Marshal the Buffer (Byte() or Byte array) to an unmanaged LPArray.
So that's it. Hope this helps somebody.

My next issue? The unmanaged code firing an event in my code!!! Look here! I know the unmanaged code is recognizing events, because it makes my code throw an exception. Not sure why, or how to troubleshoot.

Friday, December 17, 2004

Another C++ to VB conversion, a Buffer?

// Pointer to tranfser buffer
unsigned char* theBuffer = NULL;

In .Net (Visual Basic) how do I do that?

Thursday, December 16, 2004

So, I posted my question...

To MSDN. You can reply here, there, or e-mail. I'm also going to go through old posts, and clean up the code so it's a little more readable.

Wednesday, December 15, 2004

For my next trick

Okay, so I'm able to pass strings out now. ByRef/ByVal... stupid fat fingers.

My next step is to convert this function into VB: (I will be working on it tomorrow. GENERICREAD?!?!)
KPDCStatus CreateDestinationFile( KPDCProcsPtr pProcs,
KPDCLibMgrRef libMgr,
char* fileName,
KPDCFileRefHandle* fileRef)
KPDCStatus theStatus = KPDC_OK;
char theFilePath[MAX_STRING_LENGTH];
KPDCUInt32 theAttributeSize = 0;

// Set up the file path
strcpy(theFilePath, "C:\\");
strcat(theFilePath, fileName);

// Create the file
theFileHandle = CreateFile( theFilePath,
if(theFileHandle == INVALID_HANDLE_VALUE)
theStatus = (KPDCStatus) GetLastError();
*fileRef = (KPDCFileRefHandle) theFileHandle;


More on this project

Okay, the big issue I was having was that my functions would end an an unhandled exceptrion would occure. I figured out that the IntPtrs I was passing to the unmanaged code were getting GC'd when my function ended. But the unmanaged code was still trying to use it. So I made the IntPtrs global, an it worked.

Here's the new one. I posted on MSDN. I need to deal with events. I don't know what events the DLL raises, but it has a method where you can pass your function to the unmanaged code.

The function definition looks like this:
KPDCStatus KPDCSetCameraEventNotification ( KPDCCameraRef inCameraRef, KPDCCameraEventNotificationFunc inNotificationFunc, void *inUserData);

In the demo code, they provide a typedef that looks like this:
typedef void (KPDCCALLBACK *KPDCCameraEventNotificationFunc)(
KPDCUInt32 inEvent, // The event code, see KPDCCameraEvents
KPDCUInt32 inParam1, // Events may have an integer parameter
const char *inParam2, // Events may have a string parameter
KPDCUInt32 inParam2Length,
void *userData);

Tuesday, December 14, 2004

I got it to take a picture

I've gotten my software to snap the camera, taking a picture. Now I have to refactor the code, cleaning it up, and putting necessary funcionality into the wrapper as opposed to my test code.

I also need to handle events given out by the unmanaged DLL.

I also have pics of my apartment.

Marshaling Samples, 'Let's play nice now Pardna'

Woa, this is a breakthrough for me. Check out this article on MSDN. Some Marshaling examples. I'm gonna print these out I think.

Monday, December 13, 2004

HandleRef examples in VB .Net

Anybody? In my last post I posted native function declarations, and what I did to wrap them. I used a bunch of IntPtrs. I'm thinking, after some reading and followups on newsgroups, that I should be using HandeRefs, at least some of the time.

Do you have any examples? (ie. Iterators, Strings, Ints, etc.)

When should you use HandleRefs, as opposed to IntPtrs?

Some of my C++ to VB conversions

So, I have C++ function declarations, and their VB wrappers. Anybody see anything wrong with them?

TypeDefs in demo C++ code:
typedef void* KPDCOpaqueRef;
typedef KPDCOpaqueRef KPDCLibMgrRef;
typedef KPDCOpaqueRef KPDCIteratorRef;
typedef KPDCIteratorRef KPDCCameraIterRef;
typedef KPDCOpaqueRef KPDCCameraRef;
typedef KPDCIteratorRef KPDCPropertyIterRef;
typedef KPDCOpaqueRef KPDCPropertyRef;
typedef KPDCIteratorRef KPDCDirectoryIterRef;
typedef KPDCOpaqueRef KPDCDirItemRef;
typedef KPDCOpaqueRef KPDCIORef;
typedef KPDCOpaqueRef KPDCImageRef;

Native Def:
//Get the size and type for the specified attribute ID.//
KPDCStatus KPDCGetAttributeInfo(KPDCOpaqueRef inRef, KPDCAttributeID inAttrID, KPDCDataTypes *outAttrType, KPDCUInt32 *outAttrSize);

My wrap:
Declare Auto Function KGetAttributeInfo Lib "DCSPro4SLR.dll" Alias "KPDCGetAttributeInfo" (ByVal inRef As IntPtr, ByVal inAttrID As Integer, ByRef outAttrType As KPDCDataTypes, ByRef outAttrSize As Integer) As Integer

Native Def:
//Get the value of the specified attribute ID. If the attribute is the KPDCPropValueID of a property, then the value of the property will be retrieved from the camera.//
KPDCStatus KPDCGetAttributeValue(KPDCOpaqueRef inRef, KPDCAttributeID inAttrID, KPDCUInt32 *inOutAttrSize,

My wrap:
Declare Auto Function KGetAttributeValue Lib "DCSPro4SLR.dll" Alias "KPDCGetAttributeValue" (ByVal inRef As IntPtr, ByVal inAttrID As Integer, ByRef inOutAttrSize As Integer, ByVal outAttrValue As IntPtr) As Integer

Native Def:
//Allocate a property iterator for camera properties.//
KPDCStatus KPDCAllocPropertyIterator ( KPDCCameraRef inCameraRef, KPDCPropertyIterRef *outRef);

My Wrap:
Declare Auto Function KAllocPropertyIterator Lib "DCSPro4SLR.dll" Alias "KPDCAllocPropertyIterator" (ByVal inCameraRef As IntPtr, ByRef outRef As IntPtr) As Integer

Native Code:
//Return a reference to the first item that has the string specified by inName and the value of its name attribute. The iterator points to the found item. A subsequent call to KPDCIteratorNext returns the item following the found item in the list.//
KPDCStatus KPDCIteratorFind(KPDCIteratorRef inIteratorRef, const char *inName, KPDCOpaqueRef *outFoundItemRef);

My Wrap:
Declare Auto Function KIteratorFind Lib "DCSPro4SLR.dll" Alias "KPDCIteratorFind" (ByVal inIteratorRef As IntPtr, ByVal inName As System.Text.StringBuilder, ByRef outFoundItemRef As IntPtr) As Integer

Native Code:
//Return a reference to the next enumerated item. After creating a new iterator or calling KPDCIteratorReset, this function returns the first item. If there are no more items, outNextItemRef will not be valid.//
KPDCStatus KPDCIteratorNext(KPDCIteratorRef inIteratorRef, KPDCOpaqueRef *outNextItemRef);

My Wrap:
Declare Auto Function KIteratorNext Lib "DCSPro4SLR.dll" Alias "KPDCIteratorNext" (ByVal inIteratorRef As IntPtr, ByRef outNextItemRef As IntPtr) As Integer

Native Code:
//Reset the iterator to point to the beginning of the list.//
KPDCStatus KPDCIteratorReset(KPDCIteratorRef inIteratorRef);

My Wrap:
Declare Auto Function KIteratorReset Lib "DCSPro4SLR.dll" Alias "KPDCIteratorReset" (ByVal inIteratorRef As IntPtr) As Integer

Okay, latest and greatest on this project.

I have a button that calls an unmanaged function looking at the properties in the camera. I'm getting a NullReferenceException AFTER the function runs in

I declare a bunch of IntPtrs at the begining of my class that are all Private. (The .Dispose method calls a function called FlushIt, that calls an unmanaged function to clear those IntPtrs.)

Here's the function. Remember, it's after this that I get my errors. But something here probably isn't getting cleared correctly. The function calls unmanaged code to walk an iterator which was created by unmanaged code. I've also included the Private Declarations of the IntPtrs. 'myPro4' is the managed wrapper to the unmanaged DLL.
'References, IntPtrs, for each one of these you must
'Add a FreeRef command in FlushIt
Private myLibMgr As IntPtr = Marshal.AllocHGlobal(1)
Private myCamIter As IntPtr = Marshal.AllocHGlobal(1)
Private myDirItemRef As IntPtr = Marshal.AllocHGlobal(1)
Private myIORef As IntPtr = Marshal.AllocHGlobal(1)
Private myCameraRef As IntPtr = Marshal.AllocHGlobal(1)
Private myPropIter As IntPtr = Marshal.AllocHGlobal(1)
Private myPropRef As IntPtr = Marshal.AllocHGlobal(1)
'End References, IntPtrs

Private Sub FireCamera()
Dim thisCamera As String 'How we know what camera we're on as we iterate.
Dim theSize As Integer = 0
Dim theDataType As Integer = 0
Dim ptrToAttrib As IntPtr = Marshal.AllocHGlobal(1)
Dim ptrToLabel As IntPtr = Marshal.AllocHGlobal(1)

'Look for the camera
'Get the camera reference
myStatus = myPro4.KIteratorNext(myCamIter, myCameraRef)

'Get the serial
myStatus = myPro4.KGetAttributeInfo(myCameraRef, 501, theDataType, theSize)
If myStatus = 0 Then myStatus = myPro4.KGetAttributeValue(myCameraRef, 501, theSize, ptrToAttrib)
thisCamera = Marshal.PtrToStringAnsi(ptrToAttrib)

Loop Until thisCamera = useCamera

'Get the Iterator of properties for the camera
myStatus = myPro4.KAllocPropertyIterator(myCameraRef, Me.myPropIter)

'Get the reference to the 'saveEnable' property
If myStatus = 0 Then
Dim theProperty, theLabel As String
myStatus = myPro4.KIteratorNext(myPropIter, myPropRef)

'Get the serial
myStatus = myPro4.KGetAttributeInfo(myPropRef, 1004, theDataType, theSize)
If myStatus = 0 Then
myStatus = myPro4.KGetAttributeValue(myPropRef, 1004, theSize, ptrToAttrib)

If myStatus = 0 Then
theProperty = Marshal.ReadInt32(ptrToAttrib)
End If

myStatus = myPro4.KGetAttributeValue(myPropRef, myPro4.KPDCPropEnumValueLabelID(Marshal.ReadInt32(ptrToAttrib)), 256, ptrToLabel)
If myStatus = 0 Then
theLabel = Marshal.PtrToStringAnsi(ptrToLabel)
End If

End If

Call Me.WriteOutput(theLabel & " - " & theProperty)

myStatus = myPro4.KIteratorNext(myPropIter, myPropRef)

Loop Until myStatus <> 0

WriteOutput("Could not load camera properties")
End If

'Clean up a bit
myStatus = myPro4.KIteratorReset(myCamIter)

Catch ex As Exception
Call Me.WriteOutput(ex.ToString)


End Try
End Sub

Friday, December 10, 2004

Kodak's DCS SDK

Kodak's Digital Camera System SDK can be found here.

Out standing issues on my current project

I am developing a .Net wrapper for Kodak's Digital Camera System SDKs. These are basically the DLLs for handling Kodak's Pro cameras, like the 14n.

The documentation is good, but in C++. So the stuff I want to do I need to convert to VB .Net, cause that's what I know. (Tho I'm getting a crash course in C++.)

Issue #1
This occurs when the following code runs:
Private Sub btnTest1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest1.Click
Call FillCameras() <---
End Sub

Now, the first thing you'll say is, 'FillCameras is your problem. Something in there.' And you may be right, but the weird thing is, if I put a breakpoint at that line (with <---) and let the program/code run after it pauses, no problem. Once it runs once, I can remove the breakpoint and fire this button at will.

Issue #2
I get StackOverflowExceptions at other times. Is there a way to know why? The code seems to go fine. I go through a number of things, firing functions I've wrapped, and getting somewhat expected results. But when my function ends, I get the overflow. Is Garbage Collector trying to clean up and puking? How can I troubleshoot this? I don't get much debugging info in the way of code to read, it's something behind the scenes.

Thursday, December 09, 2004

More to sell...

I'm posting more items to my e-bay auctions. Please take a look. I have some electronics, as well as some Dolls that will be going up.

An atheist believes in god...

Famous Atheist, Antony Flew, at age 81 has announced he now believes in a god... of some sort.
At age 81, after decades of insisting belief is a mistake, Antony Flew has concluded that some sort of intelligence or first cause must have created the universe. A super-intelligence is the only good explanation for the origin of life and the complexity of nature, Flew said in a telephone interview from England.
The derivatives that Catholicism/Protestantism have portrayed of god have lost so much of the god of the bible, it's no wonder people can't put their faith in it. But also, people are finding it harder to swallow evolution as the supreme source of life. If people dig a little deeper, they'll find the answers.

Wednesday, December 08, 2004

Okay, so I’m a novice programmer.

What may seem glaringly obvious, or extremely exciting, probably won’t do much for me. Learning how to write a text file? Now that was exciting.

But as I learn and grow in this competitive and fast moving environment I look over things that are now old news and WOW! It all comes clear.

.Net was where I started. So it was hard for me to see how wonderful it made life. As I try to wrap an unmanaged library the beauty of .Net screams out. Metadata!!!

If I need to consume a .Net based Web Service, Metadata tells me all about the functions, properties and other goodies I need to consume it. If I need to use functionality in a managed library, Metadata makes Intellisense possible.

If I want to access an unmanaged library, it’s locked up tighter than Fort Knox. There is nothing to tell me the names of the functions, let alone their signatures. I don’t know what it does or what I can use it for unless I troll through documentation or find source code that uses it.

I guess I’ve had the easy life as far as becoming a programmer is concerned. With such a beefy framework and so much experience as far as programming is concerned, it’s like nuclear science. My grandparents had no idea what went into nuclear power, I learned it in grammar school.

I know, I'm posting too much...

But this is a real interesting article. I specifically noted this paragraph:
Since the time of Adam Smith, we've used the wealth of nations as a proxy for the well-being of nations. We measure whether life is getting better by checking whether the good numbers (GDP, personal incomes, and so on) are going up and the bad numbers (unemployment, inflation, and so on) are going down. However, over the past half century, something strange has happened. The US's per capita GDP - the value of all the goods and services a nation produces divided by its population - has nearly tripled, but American well-being hasn't budged. We've grown almost three times richer but not one jot happier. There's ample evidence that in all postindustrial societies, material wealth and broader happiness are no longer closely in sync.

So more money isn't more happiness? But that seems to be the only focus of the world, to make more money.

1500 visits! And new tech links!

Yes, we did it. Yesterday, my simple little site had it's 1,500th visit. Maybe that's not much, but it's good to remember those milestones.

As for tech, I should be getting a fire-wire card today at work, so I can test out tethered operation.

Also, I was offered this site as a reference for NUnit with VB. I've read it over briefly, and it's worthy of posting about. I'm going to work through the practice exercise ASAP.

My buddies, Dan and Jerry got back from Germany. Their pics are up if you know them and care to look. Dan's weblog is listed under my 'Friend Links' section.

Tuesday, December 07, 2004

One more thing...

I've looked up the local INETA associated .Net users group, Central Penn .Net. Figured it's be good to have local coders in my network of contacts.

New additions

I've made some additions to my Clive Cussler book page. You can now order any of the books listed there. Please do, they're very good.

So, what's the news?!?!

Update: I changed a question to a statement. I will be moving!
I guess I can tell you now, everybody else that needs to know first knows.

My wife and I will be moving to the Lebanon, PA area at the end of December!

What does this mean for my weblog? Not much, there might be a gap in posting, but hopefully not much.

What does this mean about the current project, Wrapping an unmanaged DLL? I would like to finish that. I don't think it will take too much more. They've written the hard code, I'm just wrapping it.

Anybody know anyone down that area looking for somebody to work for them? Let me know. I've tried to line up a job, but I've only gotten some nibbles.

Monday, December 06, 2004

An ambitious project

The software I developed for my company, has performed well for our customers, causing them to choose it over offerings by Kodak (Groups) and PhotoLynx (SPS). The one shortcoming, photographers want the software tethered to the camera. That is, when the camera takes a picture, it is imediatly in the software, ready to be flagged with the student's information.

Well, Kodak does offer an SDK. It consists of 3 libraries (DLLs) and some sample code. The code is in C++ and was written using Visual Studio 6.0. My mission, that I've seemed to have accepted, is to write a managed code wrapper, using Visual Basic .Net, so that my software can consume and tether to the Kodak cameras.

Right now, I am at a standstill. I believe I have written code that will initialize and talk to the camera, but I don't have the cable to connect the camera to the PC for testing. So right now I get error codes from the .DLLs saying they can't initialize, which makes sense. But I also get this:
System.Runtime.InteropServices.MarshalDirectiveException: PInvoke restriction: can not return variants.

Here's the code that does it:
Dim myLibMgr As IntPtr = Marshal.AllocHGlobal(1)
Dim myCamIter As IntPtr = Marshal.AllocHGlobal(1)

myStatus = myPro4.KInitialize(KodakDCSIntf.Pro4.KPDCInitalizationOptions.KPDCInitOptionEnableIEEE1394, myLibMgr)

myStatus = myPro4.KAllocCamera(myLibMgr, myCamIter) <-----

I've wrapped the DLL like so:
Declare Auto Function KAllocCamera Lib "DCSPro4SLR.dll" Alias "KPDCAllocCameraIterator" (ByVal inManagerRef As IntPtr, ByRef outRef As IntPtr)

I think that it's not sure what to do, or the myLibMgr object is not valid. In the demo code, it doesn't get to AllocCamera if Initialize doesn't return a valid response (myStatus = 0).

Another link and a teaser

I put another link on my sidebar here, but it's a link to a page of links. I am going to start saving useful programming links to this page so that others can benefit from them. As I get more I will sort them out, but this is a start. I have many to put there, but these are some good ones.

Also, I will be putting some REALLY BIG NEWS here soon, so keep watching. (No, we're not having a kid.)

Friday, December 03, 2004

Continuing to try to understand

It seems there is much in life and in programming I do not understand.

I have this code:
typedef KPDCUInt8* KPDCPointer;

typedef enum
KPDCRed = 0, // Currently, RGB is all we got.
KPDCGreen = 1,
KPDCBlue = 2,

KPDCMaxNumComponents = 8 // The maximum number of components conceivable.
} KPDCColorComponents;

typedef struct

KPDCPointer componentPtr[KPDCMaxNumComponents];
// Array of pointers to the components,
// indexed by KPDCColorComponents.
} KPDCPixelLayout;

typedef enum
KPDC_CameraModelUnknown = 0,
KPDC_ProBackCamera = 0x4000,
KPDC_ProBack645 = 0x4001,

} KPDCModelCodes;

I want to do the same thing in VB .Net. I know how to do structures and enumerators. What I don't know is what to do about the pointer, and then what to do about the last enum mentioned (KPDCModelCodes). How do I get those values into VB.Net?


There's something I'm learning. There's water, and there's beer. You might have soda, or maybe fruit juice. But when it comes to most consumed, it's water or beer. Programmers, geeks, and techies are big fans of beers.

Take a look at my friend's site. This is a page on his site talking about some of his beer tours. The first one on the page is the New England area. I must say, however, if he comes through again, he may want to take a look at Long Trail. I am wondering at his opinion. He does mention a good Black and Tan recipe.

I hope to some day soon have the room and time to invest in brewing at home. Knowing several 'home brewers' has given me a desire to try it myself. That, and the fact that on a Sunday night, with nothing to do, and no 'cold ones' in my fridge, I cannot run to the store to purchase beer. Thanks Connecticut.

I've got the power!!!

I set up an FTP site at home last night. Tried to button it up tight. It's nice, I was able to send files from work right to my home PC. Maybe I'll get it set up so I can edit my home site when I'm away. I'll see. It's just nice to have the flexibility.

Thursday, December 02, 2004

New things I'm learning

I'm trying to write a managed code wrapper for some libraries written in VC++ 6. I have sample code, also written in C++. I'm a bit rusty on C++, so I dusted off a few of my books, to try to learn a bit more about this language. What I put here is for anybody's benefit, but mostly for my own memory.

I started seeing function declarations like this:
void myFunction(int varA, void *varB)

What's this *varB? Well, in VB.Net, it's passing the variable 'by reference'. You'ld do it like so:
myFunction(ByVal varA As Integer, ByRef varB As Object)

In C++ this is called indirection, and varB would be called a pointer. C++ can use this to access stuff off the heap, as opposed to the stack.

Whoa!!! What are you talking about now!?!?

More fun stuff I learned. The term stack refers to the area of memory allocated to your program. The term heap refers to the computer's virtual memory. Stack is like inside your sandbox, all alone, safe and sound. Heap is the rest of the playground with all the other children, where you might get your toes stepped on.

Hope that clears things up for us all.

Ah... so that's what P/Invoke is...

Found this, thanks to David Browne on MSDN newsgroups. (Aren't VB guys nicer already?)

The article on MSDN is here.

Basically I have this .dll that provides certain functionality I want. How do I use it? Well... this article tells me how. I will now continue to read and learn? Hope this post helps you find what you need.

Wednesday, December 01, 2004

Now I know why I've done mostly Visual Basic

The people. The C++ people seem mean. Maybe I'm biased, I've only received replies from 1 guy. But hey, if the others are so nice, why don't they help.

I downloaded some C++ stuff (Visual C++ 6.0) and converted it to 2003. I go in and try to compile... Files are all over the place, nowhere to be found. So I have to go through all the includes, specify the paths... Then I compile again.

LINK : fatal error LNK1181: cannot open input file '.\debug\KPDCLoader_Win.obj'

Hmm... Okay, it can't find that file. I can't find it either. Well, it's a Linker error, maybe there's a problem linking some files, the paths were all messed up.
So, I hit F1, and get this:

cannot open input file 'filename'

The linker could not find filename because it does not exist or the path was
not found.

A lot of help that was. So I go on to MSDN's newsgroups. I don't know any sites, or tutorials, all my C++ books are at home, maybe I'd find a friendly ally to help me out. Here is my first reply:
Put the blinking cursor in the 'Build' window on the error code and press
F1. The help should be quite informative.

Yeesh... Come to find out, one of the .c files the project had listed, wasn't in the correct folder, the path was invalid. But I didn't get a message for that, the linker skipped that, and tried to run the file it hadn't created. Fun, fun.