From fbb27d683d8b4af787c036e882e36537dce1e42d Mon Sep 17 00:00:00 2001 From: Jackie Li Date: Fri, 1 Dec 2023 17:48:24 +0000 Subject: [PATCH] fix ptr types --- Main.bas | 18 ++++++++---------- WinHttpCommon.bas | 6 +++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Main.bas b/Main.bas index bc72ad6..20dbb47 100644 --- a/Main.bas +++ b/Main.bas @@ -17,10 +17,10 @@ Dim sizeStatusCode As Long ' for HTTP result request sizeStatusCode = 4 ' four bytes for long ' for HTTP result request dwError = ERROR_SUCCESS fStatus = False -Dim hSessionHandle As Long -Dim hConnectionHandle As Long -Dim hRequestHandle As Long -Dim hWebSocketHandle As Long +Dim hSessionHandle As LongPtr +Dim hConnectionHandle As LongPtr +Dim hRequestHandle As LongPtr +Dim hWebSocketHandle As LongPtr hSessionHandle = 0 hConnectionHandle = 0 hRequestHandle = 0 @@ -31,8 +31,7 @@ Dim AgentHeader As String AgentHeader = "Websocket Sample" ' Create session handle -hSessionHandle = WinHttpOpen(StrPtr(AgentHeader), _ - WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, 0, 0, 0) +hSessionHandle = WinHttpOpen(StrPtr(AgentHeader), WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, 0, 0, 0) If hSessionHandle = 0 Then dwError = GetLastError GoTo quit @@ -40,7 +39,7 @@ End If ' Server Name Dim ServerName As String -ServerName = "echo.websocket.org" +ServerName = "ws.vi-server.org" ' Server Port Dim Port As Long @@ -56,7 +55,7 @@ End If ' Request Method & Path Dim method As String, Path As String method = "GET" ' always -Path = "/" ' echo.websocket.org +Path = "/mirror" ' echo.websocket.org ' Create request handle - use 0 for null pointer to empty strings: Version, Referrer, AcceptTypes hRequestHandle = WinHttpOpenRequest(hConnectionHandle, StrPtr(method), StrPtr(Path), 0, 0, 0, 0) @@ -160,7 +159,7 @@ Dim dwBufferLength As Long ' get correct value in case of change to buffer size dwBufferLength = (UBound(rgbBuffer) - LBound(rgbBuffer) + 1) -Dim pbCurrentBufferPointer As Long +Dim pbCurrentBufferPointer As LongPtr pbCurrentBufferPointer = VarPtr(rgbBuffer(0)) Dim dwBytesTransferred As Long dwBytesTransferred = 0 @@ -283,4 +282,3 @@ End Sub - diff --git a/WinHttpCommon.bas b/WinHttpCommon.bas index 55c8304..27413ce 100644 --- a/WinHttpCommon.bas +++ b/WinHttpCommon.bas @@ -138,8 +138,8 @@ Public Declare PtrSafe Function WinHttpWebSocketReceive Lib "winhttp" ( _ ByVal hWebSocket As LongPtr, _ ByRef pvBuffer As Any, _ ByVal dwBufferLength As Long, _ - ByRef pdwBytesRead As LongPtr, _ - ByRef peBufferType As LongPtr _ + ByRef pdwBytesRead As Long, _ + ByRef peBufferType As Long _ ) As Long Public Declare PtrSafe Function WinHttpWebSocketClose Lib "winhttp" ( _ @@ -154,7 +154,7 @@ Public Declare PtrSafe Function WinHttpWebSocketQueryCloseStatus Lib "winhttp" ( ByRef usStatus As Integer, _ ByRef pvReason As Any, _ ByVal dwReasonLength As Long, _ - ByRef pdwReasonLengthConsumed As LongPtr _ + ByRef pdwReasonLengthConsumed As Long _ ) As Long Public Declare PtrSafe Function WinHttpQueryHeaders Lib "winhttp" ( _