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.

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";
	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
	// 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++)
				lpszDivider, cfc[i].szHeading, cfc[i].szBodyText);
			m_strText += strFormat;
		// Error - show a message
		switch (dwResult)
			AfxMessageBox("The file was to small.");
			AfxMessageBox("This is not a valid cardfile database.");
			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);

	// Make sure that the contents of the string with the cardfiles are shown
	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


  • 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?

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

Top White Papers and Webcasts

  • Complex hybrid environments can make it difficult to track interdependencies, increasing the risk of disrupting critical business services. In this white paper by EMA, you'll learn how application discovery and dependency mapping can help you: Meet granular targets for availability, cost, and time-to-revenue for cloud services. Accelerate mean time to repair (MTTR) while communicating better with stakeholders. Manage even the most complex hybrid environments more efficiently and effectively Understand the …

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date