Support Board
Date/Time: Sat, 30 Nov 2024 03:40:45 +0000
ACSIL: Example build script using udp commands to unload / load dlls
View Count: 2637
[2018-11-27 04:48:55] |
User654912 - Posts: 26 |
You will need to adapt this to your system. You will need to have installed the compiler from Sierra Chart. Save this file as build.ps1 and run it from powershell with: .\build.ps1 ----- function Send-UdpDatagram
{ Param ([string] $EndPoint, [int] $Port, [string] $Message) $IP = [System.Net.Dns]::GetHostAddresses($EndPoint) $Address = [System.Net.IPAddress]::Parse($IP) $EndPoints = New-Object System.Net.IPEndPoint($Address, $Port) $Socket = New-Object System.Net.Sockets.UDPClient $EncodedText = [Text.Encoding]::ASCII.GetBytes($Message) $SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints) $Socket.Close() } Send-UdpDatagram -EndPoint "127.0.0.1" -Port 22903 -Message "RELEASE_DLL--C:\SierraChart\Data\mydll.dll" cmd.exe /c "C:\SierraChart\Data\VisualCCompile.Bat" Send-UdpDatagram -EndPoint "127.0.0.1" -Port 22903 -Message "ALLOW_LOAD_DLL--C:\SierraChart\Data\mydll.dll" Date Time Of Last Edit: 2018-11-27 04:50:11
|
[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
|
To post a message in this thread, you need to log in with your Sierra Chart account: