Using the UNICODE version of LEADTOOLS in a non-UNICODE Application

Take the following steps to create and run a program that uses the UNICODE version of LEADTOOLS in a non-UNICODE application.

  1. Start Visual Studio 2008.

  2. 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.

  3. From the main menu, select Project->Properties. Under Configuration\General, set the "Character Set" to "Not Set". Click OK.

  4. 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 

  5. 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 

  6. 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; 
    } 

  7. Press CTRL+F5 to build and run your application to test it.

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.