Microsoft Cardfile Import DLL

What is cardfile?
If you ask this question, youe propably don't need this dll. Anyway - the screenshot is showing Cardfile in action (with the contents of my CD-archive.)

CardFile.exe came with windows 3.1 and 3.11 (maybe before) but was not included with Windows 95 and later. That is a shame because I think lot's of people was using this small, but inferior, piece of software.

What is the CardFile Import DLL?
I have written a small DLL (28 Kb) that will take care of importing the Cardfile binary format into something that can be understood by C++ and maybe other programming languages. I will not take any responsibility for the outcome of using this DLL. The Cardfile file format is not documented, and the only thing I know is that it works fine on my machine. I cannot guarantee that this will be the case on any system in the world.

Usage
The DLL only contains two functions:

ImportCardFile and FreeCardFilePtr.

These funtions are loaded dynamically. This approach makes using the functions a bit cumbersome, but on the other hand it means that the dll should also be usable to any programming language supporting dll function calls. You are however free to remove the header and implementation files from dll and link them statically to your own project, if you do not like DLLs.

The code snippet below is taken from the sample accompanying the cardfile dll.

BOOL CCrdFileDriverDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
// It is not necessary to call the base clas implementation of OnOpenDocument()
//	if (!CDocument::OnOpenDocument(lpszPathName))
//		return FALSE;

	HINSTANCE        hInst;
	LPCSTR		     lpszDllPath = "CardFile.dll";
	IMPORTCARDFILE	 ImportCardFile;
	FREECARDFILEPTR	 FreeCardFilePtr;
	LPCARDFILECARD	 cfc;
	DWORD		     dwNumCards, dwResult;
	LPCSTR			 lpszDivider = "========================================";
	CString			 strFormat;

	// Load the carfile dll, and obtain a pointer to the import function
	hInst = LoadLibrary(lpszDllPath);
	if (!hInst)
	{
		AfxMessageBox("Cannot load the cardfile DLL");
		return FALSE;
	}

	ImportCardFile = (IMPORTCARDFILE)GetProcAddress(hInst, "ImportCardFile");
	if (!ImportCardFile)
	{
		AfxMessageBox("Cannot find the \"ImportCardFile\" process");
		return FALSE;
	}

	// Empty the string that will be shown in the edit control of the child window
	m_strText.Empty();
	
	// call the function that imports the cardfile. Each car will be loaded into a separate structure
	dwResult = ImportCardFile(lpszPathName, &cfc, &dwNumCards);

	// The cards was imported successfully
	if (dwResult == CF_SUCCESS)
	{
		// For each of the cards create string and add it to the main string m_strText
		// The main string will eventually be shown in the edit window
		for (DWORD i=0 ; i < dwNumCards; i++)
		{
			strFormat.Format("%s\r\n%s\r\n%s\r\n", 
				lpszDivider, cfc[i].szHeading, cfc[i].szBodyText);
			m_strText += strFormat;
		}
	}
	else
	{
		// Error - show a message
		switch (dwResult)
		{
		case CF_FILETOSMALL:
			AfxMessageBox("The file was to small.");
			break;
		case CF_NOTACARDFILE:
			AfxMessageBox("This is not a valid cardfile database.");
			break;
		default:
			AfxMessageBox("Cardfile import failed.");
		}
	
		return FALSE;
	}

	// Load the process that will perform clean up of the imported cards
	FreeCardFilePtr = (FREECARDFILEPTR)GetProcAddress(hInst, "FreeCardFilePtr");
	if (!FreeCardFilePtr)
	{
		AfxMessageBox("Cannot find the \"FreeCardFilePtr\" process");
		return FALSE;
	}

	FreeCardFilePtr(&cfc, dwNumCards);
	FreeLibrary(hInst);

	// Make sure that the contents of the string with the cardfiles are shown
	UpdateAllViews(NULL);
	
	return TRUE;
}

The Sample Program
I have provided a small sample program that will demonstrate how the dll is used, and what can be accomplished with it.
You can use the sample program to extract the information from your old Cardfile archives and copy and paste the information from cardfile into a database system of your choice.
If you decide to create a program using my code - CardFile98 maybe ;-) I would appreciate if you would mail a copy.

A sreenshot from the sample program is shown below

Download demo project - 37 KB



Comments

  • Cardfile format documentation

    Posted by Legacy on 06/19/1999 12:00am

    Originally posted by: Sam Hobbs

    The cardfile format is documented in Microsoft Knowledge Base Article ID Q99340, "Windows 3.1 Card File Format". I used it to write my own little cardfile viewer. My MSDN CD's are a couple of years old so I went to the online KB to verify that the documentation is still there. It is.

    Knowledge Base Article ID Q98797, "ACC: How to Import a Microsoft Windows Cardfile Data File" describes an Access user-defined function for importing files. I did not find it in the online KB articles, but I probably just did not search for it properly.

    There is also a KB article describing freeware cardfile conversion software, but using one of those would take all the fun out for us programmers, right?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • The first phase of API management was about realizing the business value of APIs. This next wave of API management enables the hyper-connected enterprise to drive and scale their businesses as API models become more complex and sophisticated. Today, real world product launches begin with an API program and strategy in mind. This API-first approach to development will only continue to increase, driven by an increasingly interconnected web of devices, organizations, and people. To support this rapid growth, …

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds