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

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • If you need new tools and tricks to make your meetings profitable and productive, then 5 Tips in 5 Minutes: A Quick Guide for More Profitable Sales Meetings is for you. Timely, practical tips that you can incorporate in just seconds will save you literally hours in travel and meeting time, not to mention help you to focus on what your sales prospects really want to know and how you can meet their needs. Get 5in5: A Quick Guide for More Profitable Sales Meetings and start building your sales the smarter, faster …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds