Click here to Skip to main content
15,843,031 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have my resource header and resource file. but it shows undefined reference to 'SCardEstablishContext@16' and 'SCardConnectA@24'
what to do?
C++
#include <windows.h>
#include <dir.h>
#include
#include
#include <stdio.h>
#include "resource.h"
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <dirent.h>
#include <winscard.h>
char print[100];
char print1[100];
/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";
HWND g_hToolbar = NULL;
char *ctoh(char *s,int len)
{
    int len1 = (len*2);
    char *hex;
    hex = (char*)malloc(len1+1);
    int i,j=0;
    for(i=0;i<len;i++)>
    {
        if(s[i]>='@'&&s[i]<='I')
        {
            hex[j] = '4';
            hex[j+1] = (s[i]-'@')+'0';
            j = j+2;
        }
        else if(s[i]>='`'&&s[i]<='i')
        {
            hex[j] = '4';
            hex[j+1] = (s[i]-'`')+'0';
            j = j+2;
        }
        else if(s[i]>='J'&&s[i]<='O')
        {
            hex[j] = '4';
            hex[j+1] = (s[i]-'J')+'A';
            j = j+2;
        }
        else if(s[i]>='j'&&s[i]<='o')
        {
            hex[j] = '4';
            hex[j+1] = (s[i]-'j')+'A';
            j = j+2;
        }
        else if(s[i]>='P'&&s[i]<='Y')
        {
            hex[j] = '5';
            hex[j+1] = (s[i]-'P')+'0';
            j = j+2;
        }
        else if(s[i]>='p'&&s[i]<='y')
        {
            hex[j] = '5';
            hex[j+1] = (s[i]-'p')+'0';
            j = j+2;
        }
        else if(s[i]>='Z'&&s[i]<='_')
        {
            hex[j] = '5';
            hex[j+1] = (s[i] - 'Z') + 'A';
            j = j+2;
        }
        else if(s[i]>='z'&&s[i]<='~')
        {
            hex[j] = '5';
            hex[j+1] = (s[i] - 'Z') + 'A';
            j = j+2;
        }
        else if(s[i] >= ' '&& s[i]<= ')')
        {
            hex[j] = '2';
            hex[j+1] =(s[i]-' ') + '0';
            j = j+2;
        }
        else if(s[i] >= '0'&& s[i]<= '9')
        {
            hex[j] = '3';
            hex[j+1] =(s[i]-'0') + '0';
            j = j+2;
        }
        else if(s[i]>='*'&&s[i]<='/')
        {
            hex[j] = '2';
            hex[j+1] = (s[i] - '*') + 'A';
            j = j+2;
        }
        else if(s[i]>=':'&&s[i]<='?')
        {
            hex[j] = '3';
            hex[j+1] = (s[i] - ':') + 'A';
            j = j+2;
        }
    }
    hex[j] = '\0';
    return hex;
}
void dhex(int n, char hex[]) /* Function to convert decimal to hexadecimal. */
{
    int i=0,rem;
    if(n<=16)
    {
        hex[0] = '0';
        rem=n%16;
        i=1;
        switch(rem)
        {
            case 10:
              hex[i]='A';
              break;
            case 11:
              hex[i]='B';
              break;
            case 12:
              hex[i]='C';
              break;
            case 13:
              hex[i]='D';
              break;
            case 14:
              hex[i]='E';
              break;
            case 15:
              hex[i]='F';
              break;
            default:
              hex[i]=rem+'0';
              break;
        }
    }
    else
    {
        while (n!=0)
        {
            rem=n%16;
            switch(rem)
            {
                case 10:
                  hex[i]='A';
                  break;
                case 11:
                  hex[i]='B';
                  break;
                case 12:
                  hex[i]='C';
                  break;
                case 13:
                  hex[i]='D';
                  break;
                case 14:
                  hex[i]='E';
                  break;
                case 15:
                  hex[i]='F';
                  break;
                default:
                  hex[i]=rem+'0';
                  break;
            }
            ++i;
            n/=16;
        }
        strrev(hex);   /* Reverse string */
    }
}
/* This is a function to open a directory in a listbox*/
void ODIR(HWND hwnd, char* s)
{
    //we are opening the directory where we have created all the profiles
    DIR *dp;
    struct dirent *ep;
    dp = opendir(s);
    char* buf;
    if(dp!=NULL)
    {
        int j=0;
        int i=0;
        while((ep=readdir(dp)))
        {
            i++;
            if(i>=3)
            {
                buf = (char*)malloc(sizeof(ep->d_name));
                strcpy(buf,ep->d_name);
                //Adding the folder name to the listbox
                SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)buf);
                //LB_SETITEMDATA is used to set some data value to the items of list box,
                //this value will be used by LB_GETITEMDATA to get the text of the item selected
                SendDlgItemMessage(hwnd,IDC_LIST, LB_SETITEMDATA,j,(LPARAM)buf);
                j++;
            }
        }
    }
    else
    {
        MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
    }
}
/* This function Calculates the length of the value field in FCP */
int callen1(int x)
{
    if(x%2==1)
        return ((x/2)+1);
    else
        return x/2;
}
/* This function converts hexadecimal number into integer */
/*long int htoi(char s[])
{
    long int val = 0;
    int x = 0;
    if(s[x]== '0' &&(s[x+1]=='x'||s[x+1]=='X'))
        x+=2;
    while(s[x]!='\0')
    {
        if(val>UINT_MAX) return 0;
        else if(s[x]>='0' && s[x]<='9')
        {
            val = val*16+s[x] - '0';
        }
        else if(s[x]>='A'&&s[x]<='F')
        {
            val = val*16 + s[x] - 'A' +10;
        }
        else if(s[x]>='a' && s[x] <= 'f')
        {
            val = val*16 + s[x] - 'a' +10;
        }
        else return 0;
        x++;
    }
    return val;
}*/
/* This function converts integer into binary */
int intobin(unsigned int dec)
{
    int i=0;
    while(dec>0)
    {
        dec=dec/2;
        i++;
    }
    int rem = i%8;
    int quo = i/8;
    if(rem>0)
    {
        quo++;
        return quo;
    }
    else
    {
        return quo;
    }

}
/* This function defines the dialogbox procedure for filling FCP Parameters of DF */
BOOL CALLBACK DlgProcDF(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
        {
             SetDlgItemText(hwnd,IDC_TAG1,"81");
             SetDlgItemText(hwnd,IDC_TAG2,"82");
             SetDlgItemText(hwnd,IDC_TAG3,"83");
             SetDlgItemText(hwnd,IDC_TAG4,"84");
             SetDlgItemText(hwnd,IDC_TAG5,"85");
             SetDlgItemText(hwnd,IDC_TAG6,"86");
             SetDlgItemText(hwnd,IDC_TAG7,"87");
             SetDlgItemText(hwnd,IDC_TAG8,"8A");
             SetDlgItemText(hwnd,IDC_TAG9,"8B");
             SetDlgItemText(hwnd,IDC_TAG10,"8C");
             SetDlgItemText(hwnd,IDC_TAG11,"8D");
             SetDlgItemText(hwnd,IDC_TAG12,"8E");
             SetDlgItemText(hwnd,IDC_TAG13,"A0");
             SetDlgItemText(hwnd,IDC_TAG14,"A1");
             SetDlgItemText(hwnd,IDC_TAG15,"A2");
             SetDlgItemText(hwnd,IDC_TAG16,"A5");
             SetDlgItemText(hwnd,IDC_TAG17,"AB");
             SetDlgItemText(hwnd,IDC_TAG18,"AC");
             return TRUE;
        }
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_DONE:
            {
                char print2[100];
                memset(print2,0x00,sizeof(print1));
                int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_NAME));
                if(len > 0)
                {
                    // Now we allocate, and get the string into our buffer
                    FILE *fp;
                    char* buf1;
                    char hex[3];
                    memset(hex,0x00,sizeof(hex));
                    char tag[100];
                    memset(tag,0x00,sizeof(tag));
                    char val1[32];
                    memset(val1,0x00,sizeof(val1));
                    char val2[32];
                    memset(val2,0x00,sizeof(val2));
                    char val3[32];
                    memset(val3,0x00,sizeof(val3));
                    char val4[32];
                    memset(val4,0x00,sizeof(val4));
                    char val5[32];
                    memset(val5,0x00,sizeof(val5));
                    char val6[32];
                    memset(val6,0x00,sizeof(val6));
                    char val7[32];
                    memset(val7,0x00,sizeof(val7));
                    char val8[32];
                    memset(val8,0x00,sizeof(val8));
                    char val9[32];
                    memset(val9,0x00,sizeof(val9));
                    char val10[32];
                    memset(val10,0x00,sizeof(val10));
                    char val11[32];
                    memset(val11,0x00,sizeof(val11));
                    char val12[32];
                    memset(val12,0x00,sizeof(val12));
                    char val13[32];
                    memset(val13,0x00,sizeof(val13));
                    char val14[32];
                    memset(val14,0x00,sizeof(val14));
                    char val15[32];
                    memset(val15,0x00,sizeof(val15));
                    char val16[32];
                    memset(val16,0x00,sizeof(val16));
                    char val17[32];
                    memset(val17,0x00,sizeof(val17));
                    char val18[32];
                    memset(val18,0x00,sizeof(val18));
                    char val19[32];
                    memset(val19,0x00,sizeof(val19));
                    char val20[32];
                    memset(val20,0x00,sizeof(val20));
                    int len2[100];
                    memset(len2,0x00,sizeof(len2));
                    memset(tag,0x00,sizeof(tag));
                    buf1 = (char*)GlobalAlloc(GPTR, len + 1);
                    GetDlgItemText(hwnd, IDC_NAME, buf1, len + 1);
                    SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)buf1);
                    sprintf(print2,"%s\\%s_DF.txt",print1,buf1);
                    char *hex2 = ctoh(buf1,len);
                    printf("%s",hex2);
                    SetDlgItemText(hwnd,IDC_VAL4,hex2);
                    free(hex2);
                    fp = fopen(print2,"w");
                    int y;
                    int len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_TAG1));
                    char* buf2;
                    buf2 = (char*)GlobalAlloc(GPTR,len1+1);
                    GetDlgItemText(hwnd,IDC_TAG1,buf2,len1+1);
                    strcpy(tag,buf2);
                    int len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL1));
                    if(len3>0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL1,val1,len3+1);
                        y = strlen(val1);
                        len2[0] = callen1(y);
                        dhex(len2[0],hex);
                        SetDlgItemInt(hwnd, IDC_LEN1, len2[0], FALSE);
                        printf("%s",hex);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[0],tag[1],hex,val1);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG2,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL2));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL2, val2, len3+1);
                        y = strlen(val2);
                        len2[1] = callen1(y);
                        dhex(len2[1],hex);
                        SetDlgItemInt(hwnd, IDC_LEN2, len2[1], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[2],tag[3],hex,val2);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG3,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL3));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL3, val3, len3+1);
                        y = strlen(val3);
                        len2[2] = callen1(y);
                        dhex(len2[2],hex);
                        SetDlgItemInt(hwnd, IDC_LEN3, len2[2], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[4],tag[5],hex,val3);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG4,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL4));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL4, val4, len3+1);
                        y = strlen(val4);
                        len2[3] = callen1(y);
                        dhex(len2[3],hex);
                        SetDlgItemInt(hwnd, IDC_LEN4, len2[3], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[6],tag[7],hex,val4);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG5,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL5));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL5, val5, len3+1);
                        y = strlen(val5);
                        len2[4] = callen1(y);
                        dhex(len2[4],hex);
                        SetDlgItemInt(hwnd, IDC_LEN5, len2[4], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[8],tag[9],hex,val5);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG6,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL6));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL6, val6, len3+1);
                        y = strlen(val6);
                        len2[5] = callen1(y);
                        dhex(len2[5],hex);
                        SetDlgItemInt(hwnd, IDC_LEN6, len2[5], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[10],tag[11],hex,val6);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG7,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL7));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL7, val7, len3+1);
                        y = strlen(val7);
                        len2[6] = callen1(y);
                        dhex(len2[6],hex);
                        SetDlgItemInt(hwnd, IDC_LEN7, len2[6], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[12],tag[13],hex,val7);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG8,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL8));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL8, val8, len3+1);
                        y = strlen(val8);
                        len2[7] = callen1(y);
                        dhex(len2[7],hex);
                        SetDlgItemInt(hwnd, IDC_LEN8, len2[7], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[14],tag[15],hex,val8);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG9,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL9));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL9, val9, len3+1);
                        y = strlen(val9);
                        len2[8] = callen1(y);
                        dhex(len2[8],hex);
                        SetDlgItemInt(hwnd, IDC_LEN9, len2[8], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[16],tag[17],hex,val9);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG10,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL10));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL10, val10, len3+1);
                        y = strlen(val10);
                        len2[9] = callen1(y);
                        dhex(len2[9],hex);
                        SetDlgItemInt(hwnd, IDC_LEN10, len2[9], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[18],tag[19],hex,val10);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG11,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL11));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL11, val11, len3+1);
                        y = strlen(val11);
                        len2[10] = callen1(y);
                        dhex(len2[10],hex);
                        SetDlgItemInt(hwnd, IDC_LEN11, len2[10], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[20],tag[21],hex,val11);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG12,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL12));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL12, val12, len3+1);
                        y = strlen(val12);
                        len2[11] = callen1(y);
                        dhex(len2[11],hex);
                        SetDlgItemInt(hwnd, IDC_LEN12, len2[11], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[22],tag[23],hex,val12);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG13,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL13));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL13, val13, len3+1);
                        y = strlen(val13);
                        len2[12] = callen1(y);
                        dhex(len2[12],hex);
                        SetDlgItemInt(hwnd, IDC_LEN13, len2[12], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[24],tag[25],hex,val13);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG14,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL14));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL14, val14, len3+1);
                        y = strlen(val14);
                        len2[13] = callen1(y);
                        dhex(len2[13],hex);
                        SetDlgItemInt(hwnd, IDC_LEN14, len2[13], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[26],tag[27],hex,val14);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG15,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL15));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL15, val15, len3+1);
                        y = strlen(val15);
                        len2[14] = callen1(y);
                        dhex(len2[14],hex);
                        SetDlgItemInt(hwnd, IDC_LEN15, len2[14], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[28],tag[29],hex,val15);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG16,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL16));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL16, val16, len3+1);
                        y = strlen(val16);
                        len2[15] = callen1(y);
                        dhex(len2[15],hex);
                        SetDlgItemInt(hwnd, IDC_LEN16, len2[15], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[30],tag[31],hex,val16);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG17,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL17));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL17, val17, len3+1);
                        y = strlen(val17);
                        len2[16] = callen1(y);
                        dhex(len2[16],hex);
                        SetDlgItemInt(hwnd, IDC_LEN17, len2[16], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[32],tag[33],hex,val17);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG18,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL18));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL18, val18, len3+1);
                        y = strlen(val18);
                        len2[17] = callen1(y);
                        dhex(len2[17],hex);
                        SetDlgItemInt(hwnd, IDC_LEN18, len2[17], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[34],tag[35],hex,val18);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG19,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL19));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL19, val19, len3+1);
                        y = strlen(val19);
                        len2[18] = callen1(y);
                        dhex(len2[18],hex);
                        SetDlgItemInt(hwnd, IDC_LEN19, len2[18], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[36],tag[37],hex,val19);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG20,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL20));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL20, val20, len3+1);
                        y = strlen(val20);
                        len2[19] = callen1(y);
                        dhex(len2[19],hex);
                        SetDlgItemInt(hwnd, IDC_LEN20, len2[19], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[38],tag[38],hex,val20);
                        memset(hex,0x00,sizeof(hex));
                    }
                }
                else
                {
                    MessageBox(hwnd, "You didn't enter Name!", "Warning", MB_OK);
                }
            }
            break;
        }
        break;
        case WM_CLOSE:
        {
            EndDialog(hwnd,0);
        }
        default:
            return FALSE;
    }
    return TRUE;
}
/* This function defines the dialogbox procedure for filling FCP Parameters of EF */
BOOL CALLBACK DlgProcEF(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
        {
             SetDlgItemText(hwnd,IDC_TAG1,"80");
             SetDlgItemText(hwnd,IDC_TAG2,"81");
             SetDlgItemText(hwnd,IDC_TAG3,"82");
             SetDlgItemText(hwnd,IDC_TAG4,"83");
             SetDlgItemText(hwnd,IDC_TAG5,"85");
             SetDlgItemText(hwnd,IDC_TAG6,"86");
             SetDlgItemText(hwnd,IDC_TAG7,"88");
             SetDlgItemText(hwnd,IDC_TAG8,"8A");
             SetDlgItemText(hwnd,IDC_TAG9,"8B");
             SetDlgItemText(hwnd,IDC_TAG10,"8C");
             SetDlgItemText(hwnd,IDC_TAG11,"8E");
             SetDlgItemText(hwnd,IDC_TAG12,"A0");
             SetDlgItemText(hwnd,IDC_TAG13,"A1");
             SetDlgItemText(hwnd,IDC_TAG14,"A5");
             SetDlgItemText(hwnd,IDC_TAG15,"AB");
             return TRUE;
        }
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_DONE:
            {
                char print2[100];
                memset(print2,0x00,sizeof(print2));
                int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_NAME));
                if(len > 0)
                {
                        // Now we allocate, and get the string into our buffer
                    FILE *fp;
                    char* buf1;
                    char hex[3];
                    char tag[100];
                    memset(tag,0x00,sizeof(tag));
                    char val1[32];
                    memset(val1,0x00,sizeof(val1));
                    char val2[32];
                    memset(val2,0x00,sizeof(val2));
                    char val3[32];
                    memset(val3,0x00,sizeof(val3));
                    char val4[32];
                    memset(val4,0x00,sizeof(val4));
                    char val5[32];
                    memset(val5,0x00,sizeof(val5));
                    char val6[32];
                    memset(val6,0x00,sizeof(val6));
                    char val7[32];
                    memset(val7,0x00,sizeof(val7));
                    char val8[32];
                    memset(val8,0x00,sizeof(val8));
                    char val9[32];
                    memset(val9,0x00,sizeof(val9));
                    char val10[32];
                    memset(val10,0x00,sizeof(val10));
                    char val11[32];
                    memset(val11,0x00,sizeof(val11));
                    char val12[32];
                    memset(val12,0x00,sizeof(val12));
                    char val13[32];
                    memset(val13,0x00,sizeof(val13));
                    char val14[32];
                    memset(val14,0x00,sizeof(val14));
                    char val15[32];
                    memset(val15,0x00,sizeof(val15));
                    char val16[32];
                    memset(val16,0x00,sizeof(val16));
                    char val17[32];
                    memset(val17,0x00,sizeof(val17));
                    char val18[32];
                    memset(val18,0x00,sizeof(val18));
                    char val19[32];
                    memset(val19,0x00,sizeof(val19));
                    char val20[32];
                    memset(val20,0x00,sizeof(val20));
                    int len2[100];
                    memset(len2,0x00,sizeof(len2));
                    memset(tag,0x00,sizeof(tag));
                    buf1 = (char*)GlobalAlloc(GPTR, len + 1);
                    GetDlgItemText(hwnd, IDC_NAME, buf1, len + 1);
                    SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)buf1);
                    sprintf(print2,"%s\\%s_EF.txt",print,buf1);
                    fp = fopen(print2,"w");
                    int y;
                    int len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_TAG1));
                    char* buf2;
                    buf2 = (char*)GlobalAlloc(GPTR,len1+1);
                    GetDlgItemText(hwnd,IDC_TAG1,buf2,len1+1);
                    strcpy(tag,buf2);
                    int len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL1));
                    if(len3>0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL1,val1,len3+1);
                        y = strlen(val1);
                        len2[0] = callen1(y);
                        dhex(len2[0],hex);
                        SetDlgItemInt(hwnd, IDC_LEN1, len2[0], FALSE);
                        printf("%s",hex);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[0],tag[1],hex,val1);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG2,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL2));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL2, val2, len3+1);
                        y = strlen(val2);
                        len2[1] = callen1(y);
                        dhex(len2[1],hex);
                        SetDlgItemInt(hwnd, IDC_LEN2, len2[1], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[2],tag[3],hex,val2);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG3,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL3));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL3, val3, len3+1);
                        y = strlen(val3);
                        len2[2] = callen1(y);
                        dhex(len2[2],hex);
                        SetDlgItemInt(hwnd, IDC_LEN3, len2[2], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[4],tag[5],hex,val3);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG4,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL4));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL4, val4, len3+1);
                        y = strlen(val4);
                        len2[3] = callen1(y);
                        dhex(len2[3],hex);
                        SetDlgItemInt(hwnd, IDC_LEN4, len2[3], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[6],tag[7],hex,val4);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG5,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL5));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL5, val5, len3+1);
                        y = strlen(val5);
                        len2[4] = callen1(y);
                        dhex(len2[4],hex);
                        SetDlgItemInt(hwnd, IDC_LEN5, len2[4], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[8],tag[9],hex,val5);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG6,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL6));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL6, val6, len3+1);
                        y = strlen(val6);
                        len2[5] = callen1(y);
                        dhex(len2[5],hex);
                        SetDlgItemInt(hwnd, IDC_LEN6, len2[5], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[10],tag[11],hex,val6);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG7,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL7));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL7, val7, len3+1);
                        y = strlen(val7);
                        len2[6] = callen1(y);
                        dhex(len2[6],hex);
                        SetDlgItemInt(hwnd, IDC_LEN7, len2[6], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[12],tag[13],hex,val7);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG8,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL8));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL8, val8, len3+1);
                        y = strlen(val8);
                        len2[7] = callen1(y);
                        dhex(len2[7],hex);
                        SetDlgItemInt(hwnd, IDC_LEN8, len2[7], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[14],tag[15],hex,val8);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG9,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL9));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL9, val9, len3+1);
                        y = strlen(val9);
                        len2[8] = callen1(y);
                        dhex(len2[8],hex);
                        SetDlgItemInt(hwnd, IDC_LEN9, len2[8], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[16],tag[17],hex,val9);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG10,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL10));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL10, val10, len3+1);
                        y = strlen(val10);
                        len2[9] = callen1(y);
                        dhex(len2[9],hex);
                        SetDlgItemInt(hwnd, IDC_LEN10, len2[9], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[18],tag[19],hex,val10);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG11,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL11));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL11, val11, len3+1);
                        y = strlen(val11);
                        len2[10] = callen1(y);
                        dhex(len2[10],hex);
                        SetDlgItemInt(hwnd, IDC_LEN11, len2[10], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[20],tag[21],hex,val11);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG12,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL12));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL12, val12, len3+1);
                        y = strlen(val12);
                        len2[11] = callen1(y);
                        dhex(len2[11],hex);
                        SetDlgItemInt(hwnd, IDC_LEN12, len2[11], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[22],tag[23],hex,val12);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG13,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL13));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL13, val13, len3+1);
                        y = strlen(val13);
                        len2[12] = callen1(y);
                        dhex(len2[12],hex);
                        SetDlgItemInt(hwnd, IDC_LEN13, len2[12], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[24],tag[25],hex,val13);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG14,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL14));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL14, val14, len3+1);
                        y = strlen(val14);
                        len2[13] = callen1(y);
                        dhex(len2[13],hex);
                        SetDlgItemInt(hwnd, IDC_LEN14, len2[13], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[26],tag[27],hex,val14);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG15,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL15));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL15, val15, len3+1);
                        y = strlen(val15);
                        len2[14] = callen1(y);
                        dhex(len2[14],hex);
                        SetDlgItemInt(hwnd, IDC_LEN15, len2[14], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[28],tag[29],hex,val15);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG16,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL16));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL16, val16, len3+1);
                        y = strlen(val16);
                        len2[15] = callen1(y);
                        dhex(len2[15],hex);
                        SetDlgItemInt(hwnd, IDC_LEN16, len2[15], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[30],tag[31],hex,val16);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG17,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL17));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL17, val17, len3+1);
                        y = strlen(val17);
                        len2[16] = callen1(y);
                        dhex(len2[16],hex);
                        SetDlgItemInt(hwnd, IDC_LEN17, len2[16], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[32],tag[33],hex,val17);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG18,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL18));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL18, val18, len3+1);
                        y = strlen(val18);
                        len2[17] = callen1(y);
                        dhex(len2[17],hex);
                        SetDlgItemInt(hwnd, IDC_LEN18, len2[17], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[34],tag[35],hex,val18);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG19,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL19));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL19, val19, len3+1);
                        y = strlen(val19);
                        len2[18] = callen1(y);
                        dhex(len2[18],hex);
                        SetDlgItemInt(hwnd, IDC_LEN19, len2[18], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[36],tag[37],hex,val19);
                        memset(hex,0x00,sizeof(hex));
                    }
                    GetDlgItemText(hwnd,IDC_TAG20,buf2,len1+1);
                    strcat(tag,buf2);
                    len3 = GetWindowTextLength(GetDlgItem(hwnd, IDC_VAL20));
                    if(len3!=0)
                    {
                        GetDlgItemText(hwnd, IDC_VAL20, val20, len3+1);
                        y = strlen(val20);
                        len2[19] = callen1(y);
                        dhex(len2[19],hex);
                        SetDlgItemInt(hwnd, IDC_LEN20, len2[19], FALSE);
                        fprintf(fp, "%c%c\t%s\t%s\n",tag[38],tag[38],hex,val20);
                        memset(hex,0x00,sizeof(hex));
                    }
                }
                else
                {
                    MessageBox(hwnd, "You didn't enter Name!", "Warning", MB_OK);
                }

            }
            break;
        }
        break;
        case WM_CLOSE:
        {
            EndDialog(hwnd,0);
        }
        default:
            return FALSE;
    }
    return TRUE;
}
/* This is a dialogbox procedure for creating a simple modal dialog box */
BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
            return TRUE;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDOK:
                EndDialog(hwnd, IDOK);
            break;
            case IDCANCEL:
                EndDialog(hwnd, IDCANCEL);
            break;
        }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
/* This function is a dialogbox procedure for dialog creating files */
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
            return TRUE;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_EF:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_FCPEF), NULL, DlgProcEF);
            }
            break;
            case IDC_DF:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_FCPDF), NULL, DlgProcDF);
            }
            break;
        }
        break;
        case WM_CLOSE:
            EndDialog(hwnd,0);
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_PRESS:
                MessageBox(hwnd, "Hi!", "This is a message",MB_OK | MB_ICONEXCLAMATION);
            break;
            case IDC_OTHER:
                MessageBox(hwnd, "Bye!", "This is also a message",MB_OK | MB_ICONEXCLAMATION);
            break;
        }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
/* This Function is the dialogbox procedure for loading files in a profile */
BOOL CALLBACK DlgProc5(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
        {
            ODIR(hwnd,print1);
            return TRUE;
        }
        break;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_OPEN:
            {
                char temp[200];
                char apdu[200];
                memset(temp,0x00,sizeof(temp));
                memset(apdu,0x00,sizeof(apdu));
                strcpy(apdu,"00E00000");
                char tag[20],length[20],value[20];
                memset(tag,0x00,sizeof(tag));
                memset(value,0x00,sizeof(value));
                memset(length,0x00,sizeof(length));
                char print2[100];
                // When the user clicks the Open button, we first get the name of the profile he has selected.
                HWND hList = GetDlgItem(hwnd, IDC_LIST);
                int count = SendMessage(hList, LB_GETCURSEL, 0, 0);
                char* buf = (char*)SendMessage(hList, LB_GETITEMDATA,count,0);
                memset(print2,0x00,sizeof(print2));
                sprintf(print2,"%s%s",print1,buf);
                FILE* fp;
                fp = fopen(print2,"r");
                if(fp==0)
                {
                    printf("couldn't read file");
                }
                else
                {
                    int i=0;
                    int x;
                    while((x= fgetc(fp))!=EOF)
                    {
                        if((x==9)|(x=='\n'))
                            continue;
                        else
                        {
                            temp[i] = x;
                            i++;
                        }
                    }
                    i = strlen(temp)/2;
                    int j = i+2;
                    char len[3];
                    dhex(j,len);
                    strcat(apdu,len);
                    dhex(i,len);
                    strcat(apdu,"62");
                    strcat(apdu,len);
                    strcat(apdu,temp);
                    printf("%s",apdu);
                    fclose(fp);
                }

                /*if(count != LB_ERR)
                {
                    if(count != 0)
                    {
                        // And then allocate room to store the list of selected items.

                        int i;
                        int *buf = (int*)GlobalAlloc(GPTR, sizeof(int) * count);
                        SendMessage(hList, LB_GETSELITEMS, (WPARAM)count, (LPARAM)buf);

                        // Now we loop through the list and remove each item that was
                        // selected.

                        // WARNING!!!
                        // We loop backwards, because if we removed items
                        // from top to bottom, it would change the indexes of the other
                        // items!!!

                        for(i = count - 1; i >= 0; i--)
                        {
                            SendMessage(hList, LB_DELETESTRING, (WPARAM)buf[i], 0);
                        }

                        GlobalFree(buf);
                    }
                    else
                    {
                        MessageBox(hwnd, "No items selected.", "Warning", MB_OK);
                    }
                }
                else
                {
                    MessageBox(hwnd, "Error counting items :(", "Warning", MB_OK);
                }*/
            }
            break;
            case IDC_CLEAR:
                SendDlgItemMessage(hwnd, IDC_LIST, LB_RESETCONTENT, 0, 0);
            break;
            case IDC_LIST:
                switch(HIWORD(wParam))
                {
                    case LBN_SELCHANGE:
                    {
                        // Get the number of items selected.

                        HWND hList = GetDlgItem(hwnd, IDC_LIST);
                        int count = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
                        if(count != LB_ERR)
                        {
                            // We only want to continue if one and only one item is
                            // selected.

                            if(count == 1)
                            {
                                // Since we know ahead of time we're only getting one
                                // index, there's no need to allocate an array.

                                int index;
                                int err = SendMessage(hList, LB_GETSELITEMS, (WPARAM)1, (LPARAM)&index);
                                if(err != LB_ERR)
                                {
                                    // Get the data we associated with the item above
                                    // (the number of times it was added)

                                    int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);

                                    SetDlgItemInt(hwnd, IDC_SHOWCOUNT, data, FALSE);
                                }
                                else
                                {
                                    MessageBox(hwnd, "Error getting selected item :(", "Warning", MB_OK);
                                }
                            }
                            else
                            {
                                // No items selected, or more than one
                                // Either way, we aren't going to process this.
                                SetDlgItemText(hwnd, IDC_SHOWCOUNT, "-");
                            }
                        }
                        else
                        {
                            MessageBox(hwnd, "Error counting items :(", "Warning", MB_OK);
                        }
                    }
                    break;
                }
                break;
        }
        break;
    case WM_CLOSE:
        EndDialog(hwnd, 0);
    break;
    default:
        return FALSE;
}
return TRUE;
}
/* This function is a dialogbox procedure for loading profiles */
BOOL CALLBACK DlgProc3(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:
        {
            ODIR(hwnd,print);
            return TRUE;
        }
        break;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_OPEN:
            {
                // When the user clicks the Open button, we first get the name of the profile he has selected.
                HWND hList = GetDlgItem(hwnd, IDC_LIST);
                int count = SendMessage(hList, LB_GETCURSEL, 0, 0);
                char* buf = (char*)SendMessage(hList, LB_GETITEMDATA,count,0);
                memset(print1,0x00,sizeof(print1));
                sprintf(print1,"%s%s/",print,buf);
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_LOADPF), NULL, DlgProc5);
            }
            break;
            case IDC_LIST:
            switch(HIWORD(wParam))
            {
                case LBN_SELCHANGE:
                {
                    // Get the number of items selected.

                    HWND hList = GetDlgItem(hwnd, IDC_LIST);
                    int count = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
                    if(count != LB_ERR)
                    {
                        // We only want to continue if one and only one item is selected.
                        if(count == 1)
                        {
                            // Since we know ahead of time we're only getting one index, there's no need to allocate an array.
                            int index;
                            int err = SendMessage(hList, LB_GETSELITEMS, (WPARAM)1, (LPARAM)&index);
                            if(err != LB_ERR)
                            {
                                // Get the data we associated with the item above (the number of times it was added)
                                int data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
                                SetDlgItemInt(hwnd, IDC_SHOWCOUNT, data, FALSE);
                            }
                            else
                            {
                                MessageBox(hwnd, "Error getting selected item :(", "Warning", MB_OK);
                            }
                        }
                        else
                        {
                            // No items selected, or more than one either way, we aren't going to process this.
                            SetDlgItemText(hwnd, IDC_SHOWCOUNT, "-");
                        }
                    }
                    else
                    {
                        MessageBox(hwnd, "Error counting items :(", "Warning", MB_OK);
                    }
                }
                break;
            }
            break;
        }
        break;
        case WM_CLOSE:
            EndDialog(hwnd, 0);
        break;
        default:
            return FALSE;
    }
    return TRUE;
}
/*This is the function for dialogbox procedure after clicking create button */
BOOL CALLBACK DlgProc1(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
    switch(Message)
    {
        case WM_INITDIALOG:// This is where we set up the dialog box, and initialise any default values
        SetDlgItemText(hwnd, IDC_TEXT, "*Enter the Profile name*");
        break;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case IDC_NEXT:
            {
                // When somebody clicks the Next button, a folder with entered name is created
                int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT));//getting length of the text entered
                if(len > 0)
                {
                    // Now we allocate, and get the string into our buffer
                    char* buf;
                    buf = (char*)GlobalAlloc(GPTR, len + 1);
                    GetDlgItemText(hwnd, IDC_TEXT, buf, len + 1);
                    strcpy(print1,print);
                    strcat(print1,buf);
                    mkdir(print1);
                    EndDialog(hwnd,0);
                    HINSTANCE hInstance = GetModuleHandle(NULL);
                    DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
                }
                else
                {
                    MessageBox(hwnd, "You didn't enter anything!", "Warning", MB_OK);
                }
            }
            break;
            case IDCANCEL:
                EndDialog(hwnd,0);
            break;
        }
        break;
        case WM_CLOSE:
            EndDialog(hwnd, 0);
        break;
        default:
        return FALSE;
    }
    return TRUE;
}
/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
        {
            memset(print,0x00,sizeof(print));
            strcpy(print,"C:\\Users\\Akshay\\Desktop\\codin application\\Smart\\Profiles\\");
            HFONT hfDefault;
            HWND hEdit;
            hEdit = CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "Load",WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                                   100, 60, 60, 35, hwnd, (HMENU)ID_LOAD, GetModuleHandle(NULL), NULL);
            if(hEdit == NULL)
                MessageBox(hwnd, "Could not create button", "Error", MB_OK | MB_ICONERROR);

            hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
            hEdit = CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "Create",WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                                   100, 100, 60, 35, hwnd, (HMENU)ID_CREATE, GetModuleHandle(NULL), NULL);
            if(hEdit == NULL)
                MessageBox(hwnd, "Could not create button", "Error", MB_OK | MB_ICONERROR);

            hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
            hEdit = CreateWindowEx(WS_EX_WINDOWEDGE, "BUTTON", "Connect",WS_CHILD | BS_DEFPUSHBUTTON | WS_VISIBLE,
                                   100, 100, 60, 35, hwnd, (HMENU)ID_CONNECT, GetModuleHandle(NULL), NULL);
            if(hEdit == NULL)
                MessageBox(hwnd, "Could not create button", "Error", MB_OK | MB_ICONERROR);

            hfDefault = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
        }
        break;
        case WM_COMMAND:
        switch(LOWORD(wParam))
        {
            case ID_CREATE:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_CREATE), NULL, DlgProc1);
            }
            break;
            case ID_LOAD:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_LOAD), NULL, DlgProc3);
            }
            break;
            case ID_CONNECT:
            {
                SCARDCONTEXT    hSC;
                LONG            lReturn;
                // Establish the context.
                lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
                                                NULL,
                                                NULL,
                                                &hSC);
                if ( SCARD_S_SUCCESS != lReturn )
                    printf("Failed SCardEstablishContext\n");
                else
                {
                    SCARDHANDLE     hCardHandle;
                    LONG            lReturn1;
                    DWORD           dwAP;

                    lReturn1 = SCardConnect( hSC,
                                            (LPCTSTR)"Rainbow Technologies SCR3531 0",
                                            SCARD_SHARE_SHARED,
                                            SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1,
                                            &hCardHandle,
                                            &dwAP );
                    if ( SCARD_S_SUCCESS != lReturn1 )
                    {
                        printf("Failed SCardConnect\n");
                        exit(1);  // Or other appropriate action.
                    }

                    // Use the connection.
                    // Display the active protocol.
                    switch ( dwAP )
                    {
                        case SCARD_PROTOCOL_T0:
                            printf("Active protocol T0\n");
                            break;

                        case SCARD_PROTOCOL_T1:
                            printf("Active protocol T1\n");
                            break;

                        case SCARD_PROTOCOL_UNDEFINED:
                        default:
                            printf("Active protocol unnegotiated or unknown\n");
                            break;
                    }
                }

            }
            case ID_PROP:
            {
                char szFileName[MAX_PATH];
                HINSTANCE hInstance = GetModuleHandle(NULL);

                GetModuleFileName(hInstance, szFileName, MAX_PATH);
                MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION);
            }
            break;
            case ID_FILE_EXIT:
                PostMessage(hwnd, WM_CLOSE, 0, 0);
            break;
            case ID_DIALOG_SHOW:
                ShowWindow(g_hToolbar, SW_SHOW);
            break;
            case ID_HELP_ABOUT:
            {
                DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hwnd, AboutDlgProc);
            }
            break;
            case ID_PROFILE:
            {
                HINSTANCE hInstance = GetModuleHandle(NULL);
                DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc1);
            }
            case ID_DIALOG_HIDE:
                ShowWindow(g_hToolbar, SW_HIDE);
            break;
        }
        break;
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            DestroyWindow(g_hToolbar);
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
        break;
        default:                      /* for messages that we don't deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    HWND hwnd;
    MSG Msg;

    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WindowProcedure;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
    wc.lpszClassName = szClassName;
    wc.hIconSm       = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON,32,32,0);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, "Window Registration Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
    hwnd = CreateWindowEx(WS_EX_WINDOWEDGE,szClassName,"SMART CARD BURNER",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,
                          CW_USEDEFAULT, 240, 220,NULL, NULL, hInstance, NULL);
    if(hwnd == NULL)
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!",MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        if(!IsDialogMessage(g_hToolbar, &Msg))
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
    }
    return Msg.wParam;
    }
Posted
Updated 25-Jun-14 6:21am
v2
Comments
Maciej Los 25-Jun-14 11:22am    
And the question is...
[no name] 25-Jun-14 11:23am    
You had to post all of this code for a linker error? Why?
Sergey Alexandrovich Kryukov 25-Jun-14 11:30am    
Did you look at your post yourself? It says
#include
#include
#include
....

Format it properly using the "pre" tags and escaping <>

However, the code hardly deserve consideration. Long switch statements and repeated "SetDlgItemText..." tells the tail. This is not programming, but is the opposite of programming. You need to write code accurately, without any repetition (programming is all about abstractions; nothing needs to be repeated), hard-coded immediate constants and the like...

—SA

First of all, please see my comment to the question (which is not a question).

Well, you are trying to call a function which you did not define, so what to ask about? You did not show even the function signature/prototype anywhere. Call only the functions which are defined and accessible in the context where you call it…

—SA
 
Share this answer
 
Comments
Maciej Los 25-Jun-14 11:56am    
+5
Sergey Alexandrovich Kryukov 25-Jun-14 13:16pm    
Thank you, Maciej.
—SA

P.S.: Still not getting all the notifications; was not notified on this your comment, as well as many others.
That's is a linker error. You correctly included the header file (winscard.h) but you missed to link with the proper library file (winscard.lib, I suppose).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900