[SOLVED] Initialize / use pointer lazarus / 62-General ---------------------------------------------------------------------- pcurtis · 2021-11-05 07:38 I have this type and a var Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  Pndu_WLAN_CONNECTION_PARAMETERS = ^Tndu_WLAN_CONNECTION_PARAMETERS;   Tndu_WLAN_CONNECTION_PARAMETERS = record    wlanConnectionMode: Tndu_WLAN_CONNECTION_MODE;    strProfile: LPCWSTR;    pDot11Ssid: Pndu_DOT11_SSID;    pDesiredBssidList: Pndu_DOT11_BSSID_LIST;    dot11BssType: Tndu_DOT11_BSS_TYPE;    dwFlags: DWORD;  end; var  pConnectionParameters : Pndu_WLAN_CONNECTION_PARAMETERS;  Every time I try to assign values (for example) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   pConnectionParameters^.dwFlags := 0;  I get a SIGSEGV. What am I missing? ---------------------------------------------------------------------- 440bx · 2021-11-05 07:45 Quote from: pcurtis on November 05, 2021, 08:38:29 amI have this type and a var Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  Pndu_WLAN_CONNECTION_PARAMETERS = ^Tndu_WLAN_CONNECTION_PARAMETERS;   Tndu_WLAN_CONNECTION_PARAMETERS = record    wlanConnectionMode: Tndu_WLAN_CONNECTION_MODE;    strProfile: LPCWSTR;    pDot11Ssid: Pndu_DOT11_SSID;    pDesiredBssidList: Pndu_DOT11_BSSID_LIST;    dot11BssType: Tndu_DOT11_BSS_TYPE;    dwFlags: DWORD;  end; var  pConnectionParameters : Pndu_WLAN_CONNECTION_PARAMETERS;  Every time I try to assign values Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   pConnectionParameters^.dwFlags := 0;  I get a SIGSEGV. What am I missing? You have a pointer to a record _definition_ but you don't have a record to point to. have something like this:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  TnduVar : Tndu_WLAN...etc_record; PconnectionParameters : ... {as you have it now } ... {somewhere in the code}   PConnectionParameters := @TndvVar; { NOW you can set the dwFlags to something }   PConnectionParameters^.dwFlags := {whatever you want } ---------------------------------------------------------------------- Thaddy · 2021-11-05 07:49 Looks like the record is not allocated. Call new() (and later dispose()) Something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  pConnectionParameters : Pndu_WLAN_CONNECTION_PARAMETERS;begin // just to show the logic. New(pConnectionParameters); pConnectionParameters^.dwFlags := 0; // and somewhere later. Dispose(pConnectionParameters); end. Alternatively you can declare the var as the T version instead of the P version. That also gives you an accessible record and does not need new/dispose. If the record already exists use the code by 440bx (our posts crossed) ---------------------------------------------------------------------- pcurtis · 2021-11-05 08:23 Thanks all