Skip to main content

Legacy software such as SmartTerminal and WSDK employed the Windows registry to store registered controller information (connection point, serial number, etc).  GalilTools and the bundled library do away with this extra information and allow the user to directly specify the connection point (e.g. IP address) for connecting hardware.  When porting to the GalilTools library, one may want to look-up the Windows Registry information in order to store this connection information for use with the GalilTools library.  Whether a config file, server, or other repository is used, it is easy to extract the data from the Windows registry using "dmccom.h"

Note, as this code includes deprecated libraries, it should be used one-time only as part of an installation or initialization routine when setting up GalilTools-based applications.   Once the connection point is determined, it can be saved to disk so that future Windows registry look-ups are unnecessary.

/*
Pull IP address out of windows registry from SmartTerminal configured controller, and connect with GalilTools communication library.
This is a simple example, designed for Ethernet controller only.

To compile:
cl regAccess.cpp "c:\program files\galil\dmcwin\lib\dmc32.lib" "C:\Program Files\Galil\GalilTools\lib\Galil1.lib"  -I "c:\program files\galil\dmcwin\include" -I "C:\Program Files\Galil\GalilTools\lib" /EHsc /MD

*/

#include <windows.h>// needed because Win32.dll uses Windows 32 api
#include <iostream> //cout
#include <string> //string data structure
#include "Galil.h" //Galiltools lib
#include "dmccom.h" //win32.dll
using namespace std;

int main(int argc, char *argv[])
{

GALILREGISTRY2  regInfo;
if (DMCGetGalilRegistryInfo2( 1 , &regInfo) !=0) {
cout << "ERROR in DMCGetGalilRegistryInfo2 " << endl;
return 1;
}

string ipaddr = regInfo.hardwareinfo.winsockinfo.szIPAddress; //pull IP address out of Windows registry

Galil g(ipaddr); //pass the IP address to GalilTools lib
cout << Galil::libraryVersion() << endl << g.connection() << endl;

return 0;
}