Is it safe to use a method's nested procedure as a winapi callback?
<p>This is the simplified scenario, in Delphi 7:</p>

<pre><code>procedure TMyClass.InternalGetData;
var
  pRequest: HINTERNET;

    /// nested Callback 
    procedure HTTPOpenRequestCallback(hInet: HINTERNET; Context: PDWORD; Status: DWORD; pInformation: Pointer; InfoLength: DWORD); stdcall;
    begin
      // [...]  make something with pRequest
    end;

begin
  pRequest := HTTPOpenRequest(...);
  // [...]   
  if (InternetSetStatusCallback(pRequest, @HTTPOpenRequestCallback) = PFNInternetStatusCallback(INTERNET_INVALID_STATUS_CALLBACK)) then
    raise Exception.Create('InternetSetStatusCallback failed');
  // [...]
end;
</code></pre>

<p>The whole thing <strong>seems to work fine</strong>, but is it really correct and safe? 
I'd like to have it encapsulated this way because it's more readable and clean. My doubt is whether the nested procedure is a simple, normal procedure or not, so that it can have its own calling convention (<code>stdcall</code>) and safely reference outer method's local variables (<code>pRequest</code>).</p>

<p>Thank you.</p>