Take the following steps to create and run a program that uses the UNICODE version of LEADTOOLS in a non-UNICODE application.
Start Visual Studio 2008.
From the main menu, select File->New->Project. In the New Project dialog, Select Visual C++\Win32 for the project type and select "Win32 Console Application" for the template. Enter a name (for example "chartest") and a location for your new project and then click OK. Click Finish on the next wizard dialog to create your new project.
From the main menu, select Project->Properties. Under Configuration\General, set the "Character Set" to "Not Set". Click OK.
Edit stdafx.h and replace the contents of the file with the following code (Note: you will have to change the path of l_bitmap.h to match the LEADTOOLS installation directory on your system):
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include "C:\LEADTOOLS21\Include\l_bitmap.h"
// TODO: reference additional headers your program requires here
Edit stdafx.cpp and replace the contents of the file with the following code (Note: you will have to change the path to the .lib files to match your system):
// stdafx.cpp : source file that includes just the standard includes
// chartest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
#pragma comment(lib, "C:\\LEADTOOLS21\\Lib\\CDLLVC10\\Win32\\Ltkrn_u.lib")
#pragma comment(lib, "C:\\LEADTOOLS21\\Lib\\CDLLVC10\\Win32\\Ltfil_u.lib")
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
Edit the project's main .cpp (for example chartest.cpp) and replace the contents of the file with the following code (Note: you will have to change the path of l_bitmap.h to match the LEADTOOLS installation directory on your system):
#include "stdafx.h"
L_INT FileInfoExample(L_VOID)
{
L_INT nRet;
FILEINFO FileInfo; /* LEAD File Information structure. */
char szMessage[1024]; /* Buffer to hold information for display. */
char szInputFile[_MAX_PATH]=MAKE_IMAGE_PATH("IMAGE3.CMP");
/* Convert non-UNICODE to UNICODE */
L_TCHAR wcsInputFile[_MAX_PATH]=L"\0";
mbstowcs(wcsInputFile, szInputFile, _MAX_PATH);
/* Get the file information */
FileInfo.uStructSize = sizeof(FileInfo);
nRet = L_FileInfo(wcsInputFile, &FileInfo, sizeof(FILEINFO), 0, NULL);
if(nRet != SUCCESS)
return nRet;
/* Convert UNICODE to non-UNICODE */
char szName[16];
wcstombs(szName, FileInfo.Name, 16);
char szCompression[20];
wcstombs(szCompression, FileInfo.Compression, 20);
/* Format the message string with data from the FILEINFO structure */
wsprintf(szMessage, "Filename: %s\n\n"
"Format: %d\n\n"
"Width: %d\n\n"
"Height: %d\n\n"
"BitsPerPixel: %d\n\n"
"Size On Disk: %ld\n\n"
"Size In Memory: %ld\n\n"
"Compression: %s",
szName,
FileInfo.Format,
FileInfo.Width,
FileInfo.Height,
FileInfo.BitsPerPixel,
FileInfo.SizeDisk,
FileInfo.SizeMem,
szCompression );
/* Display the message string */
MessageBox( NULL, szMessage, "File Information", MB_OK );
return SUCCESS;
}
int main(int argc, char* argv[])
{
FileInfoExample();
return 0;
}
Press CTRL+F5 to build and run your application to test it.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document