Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

error when compiling my API Programm thant i want to generate DLL for use in Labview!

Pls see the attachment!!I use API "GetComputerName" to programm in vc6.0 to make a dll file for use in Labview.But i get the error in the attachment. Pls give me a hand!
Download All
0 Kudos
Message 1 of 6
(3,563 Views)
Hi,

If you are using the CVI libraries on this you can use the GetCompName() function from the programmer's toolbox.
The code looks fine, the only thing that you need to change is the data type of the paramenters in CompNameLength. Just declare then using the predefined Windows datatypes; like this:

LPTSTR computerName;
DWORD compNameLength = MAX_COMPUTERNAME_LENGTH+1;
computerName = malloc(MAX_COMPUTERNAME_LENGTH+1);
GetComputerName(computerName,&compNameLength);
printf("%s",computerName);
free(computerName);


Don't forget to include windows.h where those types are defined.

Good Luck!

Juan Carlos
N.I.
0 Kudos
Message 2 of 6
(3,563 Views)
Hi,

If you are using the CVI libraries on this you can use the GetCompName() function from the programmer's toolbox. However, your code looks fine, the only thing that you need to change is the data type of the paramenters in CompNameLength. Just declare them using the predefined Windows data types; like this:

LPTSTR computerName;
DWORD compNameLength = MAX_COMPUTERNAME_LENGTH+1;
computerName = malloc(MAX_COMPUTERNAME_LENGTH+1);
GetComputerName(computerName,&compNameLength);
printf("%s",computerName);
free(computerName);


Don't forget to include windows.h where those types are defined.

Good Luck!

Juan Carlos
N.I.
0 Kudos
Message 3 of 6
(3,563 Views)
You could also do the following..

DWORD compNameLength = MAX_COMPUTERNAME_LENGTH+1;
or
unsigned long compNameLength = MAX_COMPUTERNAME_LENGTH+1;

GetComputerName(computerName, &compNameLength);
Nandan Dharwadker
Staff Software Engineer
Measurement Studio Hardware Team
0 Kudos
Message 4 of 6
(3,563 Views)
after i change "int" to "DWORD compNameLength = MAX_COMPUTERNAME_LENGTH+1", i try to generate dll. And there comes another error as following.Why!

--------------------Configuration: machinename - Win32 Debug--------------------
Linking...
Creating library Debug/machinename.lib and object Debug/machinename.exp
machinename.obj : error LNK2001: unresolved external symbol _DSSetHandleSize
Debug/machinename.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
0 Kudos
Message 5 of 6
(3,563 Views)
This is a linking error, make sure that you include kernel32.lib in your project. Also make sure that you include all the instrument driver that you may be using. CVI may include the h files for you, but you need to include in your project the lib files.

Hope that helps.

Juan Carlos
N.I.
0 Kudos
Message 6 of 6
(3,563 Views)