Pregunta

//#define WIN32_DEFAULT_LIBS 
//#pragma comment(lib, "user32.lib")
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <shlwapi.h>
#include <commctrl.h>
#include <process.h>
#include "resource.h"
#include "../vsrc003_sdk.h"

volatile int thread_state=0;
char szWinName[]="MyWin";
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
void propo_thread(void *p);

int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
{

HWND hDlg;
MSG msg ;
WNDCLASSEX wcl ;

//InitCommonControls();
memset(key_files,0,sizeof(key_files));

wcl.hInstance = hThisInst;
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = WindowFunc;
wcl.style = CS_DBLCLKS;
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hIcon = NULL;
wcl.hIconSm = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.lpszMenuName =  NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;

wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);

if(!RegisterClassEx(&wcl)) return 0 ;

hInst = hThisInst;
hDlg = CreateDialog(hThisInst,(LPCTSTR)IDD_DIALOG1,NULL,DialogFunc);

while(GetMessage(&msg, NULL, 0, 0)) 
{
if(!IsDialogMessage(hDlg, &msg)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
}

VSRC003_ServoPower(0);
VSRC003_CancelMotion();

return msg.wParam ;

}

void propo_thread(void *p)
{
int pre_inp=KEYTOTAL-1,i;
while(thread_state==1)
{
int keyinp=KEYTOTAL-1,getstate=0;

if(GetKeyState(VK_DELETE) & 0x80){
    if(VSRC003_CancelMotion()) thread_state++;
}
else if(GetKeyState(VK_ESCAPE) & 0x80){
    if(VSRC003_StopMotion()) thread_state++;
}

for(i=0;i<KEYTOTAL-1;i++){
    if(GetKeyState(chr_keytbl[i]) & 0x80){keyinp=i; break;}
}


getstate = VSRC003_GetStatus();

if(getstate==ERR_PLAYINGMOTION){
    if(keyinp!=pre_inp){
        if(VSRC003_StopMotion()) thread_state++;
    }
}

else if(getstate==0){
    if(!VSRC003_LoadMotion(key_files[keyinp])){
        if(VSRC003_PlayMotion(ENDLESS)) thread_state++;
        else{
            char spath[40];

            PathCompactPathEx(spath,key_files[keyinp],40,'\\');
            SetDlgItemText((HWND)p,IDC_MOTNAME,spath);

            pre_inp=keyinp;
        }
    }
    else SetDlgItemText((HWND)p,IDC_MOTNAME,"");
}

keyinp=pre_inp;

{
    char str[256];
    unsigned short vol;

    vol = VSRC003_GetValue(VOLTAGE_VALUE);
    sprintf(str,"%.4fV",(double)vol/1000.0f);

    SetDlgItemText((HWND)p,IDC_VOLTAGE,str);
}

Sleep(0);
}

VSRC003_StopMotion();
SetDlgItemText((HWND)p,IDC_VOLTAGE,"------------");
SendDlgItemMessage((HWND) p,IDC_MODEON,BM_SETCHECK,0,0);
thread_state=0;
}

This is the error message:

1>VSRC003_VPROPO.obj : error LNK2019: unresolved external symbol                     
__imp__PathCompactPathExA@16 referenced in function "void __cdecl propo_thread(void *)"         
(?propo_thread@@YAXPAX@Z)

1>.\Debug/VSRC003_VPROPO.exe : fatal error LNK1120: 1 unresolved externals

Could anyone please help?

¿Fue útil?

Solución

add the library: pragma comment(lib,"Shlwapi.lib")

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top