Support Board
Date/Time: Sat, 30 Nov 2024 05:35:29 +0000
Post From: ACSIL: Example build script using udp commands to unload / load dlls
[2018-11-28 01:06:59] |
TedMar - Posts: 190 |
If u use MS Visual Studio , u can Build exe for Pre and Post Script 1. Build udppre.exe #ifndef UNICODE #define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <Ws2tcpip.h> #include <stdio.h> // Link with ws2_32.lib #pragma comment(lib, "Ws2_32.lib") void main() { WSADATA wsaData; SOCKET SendSocket; sockaddr_in RecvAddr; int Port = 22903; int BufLen = 128; char SendBuf[] = "RELEASE_DLL--C:\\SierraChart\\Data\\myDLL.dll"; // --------- RELEASE_DLL ------------ //--------------------------------------------- // Initialize Winsock WSAStartup(MAKEWORD(2, 2), &wsaData); //--------------------------------------------- // Create a socket for sending data SendSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //--------------------------------------------- // Set up the RecvAddr structure with the IP address of // the receiver (in this example case "127.0.0.1") // and the specified port number. RecvAddr.sin_family = AF_INET; RecvAddr.sin_port = htons(Port); RecvAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); //--------------------------------------------- // Send a datagram to the receiver printf("Sending a datagram to the receiver...\n"); sendto(SendSocket, SendBuf, BufLen, 0, (SOCKADDR *)&RecvAddr, sizeof(RecvAddr)); //--------------------------------------------- // When the application is finished sending, close the socket. printf("Finished sending. Closing socket.\n"); closesocket(SendSocket); //--------------------------------------------- // Clean up and quit. printf("Exiting.\n"); WSACleanup(); return; } 2. Build udppost.exe #ifndef UNICODE #define UNICODE #endif #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <Ws2tcpip.h> #include <stdio.h> // Link with ws2_32.lib #pragma comment(lib, "Ws2_32.lib") void main() { WSADATA wsaData; SOCKET SendSocket; sockaddr_in RecvAddr; int Port = 22903; int BufLen = 128; char SendBuf[] = "ALLOW_LOAD_DLL--C:\\SierraChart\\Data\\MyDLL.dll"; // ------- ALLOW_LOAD_DLL -------- //--------------------------------------------- // Initialize Winsock WSAStartup(MAKEWORD(2, 2), &wsaData); //--------------------------------------------- // Create a socket for sending data SendSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //--------------------------------------------- // Set up the RecvAddr structure with the IP address of // the receiver (in this example case "127.0.0.1") // and the specified port number. RecvAddr.sin_family = AF_INET; RecvAddr.sin_port = htons(Port); RecvAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); //--------------------------------------------- // Send a datagram to the receiver printf("Sending a datagram to the receiver...\n"); sendto(SendSocket, SendBuf, BufLen, 0, (SOCKADDR *)&RecvAddr, sizeof(RecvAddr)); //--------------------------------------------- // When the application is finished sending, close the socket. printf("Finished sending. Closing socket.\n"); closesocket(SendSocket); //--------------------------------------------- // Clean up and quit. printf("Exiting.\n"); WSACleanup(); return; } Ignore Warnings ... 3.) Add them both files in VS Pre /Post builid https://docs.microsoft.com/en-us/visualstudio/ide/specifying-custom-build-events-in-visual-studio?view=vs-2017 call C:\phat-to-exe 4.) Set UDP port in Sierrachart (/Global Setin../Data...../SC Server Settings) and RESTART SC. Date Time Of Last Edit: 2018-11-28 01:09:32
|