Jump to content

NamoRamana

Members
  • Content Count

    28
  • Joined

  • Last visited

Community Reputation

3 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. NamoRamana

    NetWkstaTransportEnum API in NetAPI32.dll

    I am not sure if NetWkstaTransportEnum belongs to APIs that use netbios. "NetBIOS over tcpip" is already enabled in the case where that API is not retuning any addresses.
  2. NamoRamana

    NetWkstaTransportEnum API in NetAPI32.dll

    Yes, I tried that as well.. For all the interfaces, the addresses come out at 0s though... I also tried the solution suggested by Remy here: https://stackoverflow.com/questions/23563932/getadaptersinfo-not-working-on-delphi-xe6. This works fine. The code posted in my original post has been part of the production system. Looks like if I don't find any solution to fix that code (or any reasonable explanation as to why it works on few machines and why it isn't on others), then I might have to with alternate API suggested here. Thank you.
  3. I am running the following NetAPI32.dll > NetWkstaTransportEnum API (through JEDI JwaLM library) to get MAC address of a local machine... The API gives correct MAC addresses on somewhat older windows 10 machines.. It fails to return any MAC address on newer windows 10 machines (lEntriesRead comes out 0).. Tried both the scenarios through LAN and Wifi connectivity. Any ideas? function TForm1.GetNetAPIMacAddress: string; const NERR_Success = 0; var lStatus : NET_API_STATUS; lEntriesRead : DWORD; lEntriesTotal: DWORD; hRes: DWORD; lpBuffer : PWkstaTransportInfo0; lNBTransReq : PWkstaTransportInfo0; lServerName : WideString; i : DWORD; lMAC : string; begin Memo1.Lines.Add(''); Memo1.Lines.Add(''); Memo1.Lines.Add('=========================='); Memo1.Lines.Add('Call to NetApi32.DLL >> lStatus := JwaLM.NetWkstaTransportEnum(LPWSTR(lServerName), 0, Pointer(lpBuffer),' + sLineBreak + ' MAX_PREFERRED_LENGTH, lEntriesRead, lEntriesTotal, @hRes)'); Result := ''; lServerName := ''; hRes := 0; lStatus := JwaLM.NetWkstaTransportEnum(LPWSTR(lServerName), 0, Pointer(lpBuffer), MAX_PREFERRED_LENGTH, lEntriesRead, lEntriesTotal, @hRes); Memo1.Lines.Add('hRes: ' + IntToStr(hres)); Memo1.Lines.Add('lEntriesRead: ' + IntToStr(lEntriesRead)); Memo1.Lines.Add('lEntriesTotal: ' + IntToStr(lEntriesTotal)); Memo1.Lines.Add('lStatus: ' + IntToStr(lStatus)); try if (lStatus = NERR_Success) and (lEntriesRead > 0) then begin lNBTransReq := lpBuffer; Result := ''; for i := 0 to lEntriesRead - 1 do begin lMAC := lNBTransReq.wkti0_transport_address; // exclude disabled nics... if lMAC <> '000000000000' then begin Insert('-', lMAC, 11); Insert('-', lMAC, 9); Insert('-', lMAC, 7); Insert('-', lMAC, 5); Insert('-', lMAC, 3); Result := Result + lMAC+' '; Memo1.Lines.Add('MAC Addess: ' + Result); end; Inc(lNBTransReq); end; end; finally NetApiBufferFree(lpBuffer); end; Memo1.Lines.Add(''); Memo1.Lines.Add(''); end;
  4. NamoRamana

    My new project : WebView4Delphi

    Just want to say Thank you for this component. I needed vcl - TWebBrowser replacement for Delphi Rio.. and your component fit right into it. Thank you again and carry on! 🙂
  5. NamoRamana

    Windows Notification in Exe2 when Exe2 started from Exe1

    Yes, Exe2 requires admin rights, as it registers some COM libraries (not every single time, but only when a new library is introduced or existing COM signatures change).
  6. NamoRamana

    Windows Notification in Exe2 when Exe2 started from Exe1

    @KodeZwerg - I'm not planning to change the VCL code. Thank you for your contribution. @Remy Lebeau - I suspected GetVersionEx() as I was looking TOSVersion constructor. Thank you for your detailed reply. I do not have manifests for both Exe1 and Exe2. I will create and include (as a resource to the executable) the manifest file with "requireAdministrator" privilege in Exe2. Couple of questions - (1). Do I need to create manifest with "requireAdministrator" privilege for Exe1 as well? (2). Could you please take a look at following link that has <supportedOS> tag? As I understand, I will remove tags for Windows 7 and Windows Vista from it. https://stackoverflow.com/questions/50818954/manifest-and-getversionex
  7. NamoRamana

    Windows Notification in Exe2 when Exe2 started from Exe1

    @Remy Lebeau Thank you for your pointers.. Here is what I found after attaching the Exe2 to the IDE debugger.. TOSVersion.Check() returns falls. Looks like its looking for Windows 8 and debugger shows 'Windows 7' Here is what I get when I run Exe2 from within Delphi IDE:
  8. NamoRamana

    Windows Notification in Exe2 when Exe2 started from Exe1

    @Der schöne Günther - Thank you for suggestion. I tried removing the const and calling UniqueString(). Unfortunately it did not work.
  9. I got an unusual problem about the Windows Notification.. I implemented a basic Windows Notification in Exe2.. Following is the sample code: //ShowMessage(aMessage); vNotifiCenter := TNotificationCenter.Create(nil); try if vNotifiCenter.Supported then begin vNotification := vNotifiCenter.CreateNotification; try vNotification.AlertBody:= aMessage; vNotification.Title:= aTitle; vNotification.FireDate := Now; vNotification.EnableSound:= False; vNotifiCenter.PresentNotification(vNotification); finally vNotification.Free; end; end else ShowMessage('Not Supported'); finally vNotifiCenter.Free; end; When I double-click on Exe2 from File Explorer OR run in debug, it works fine... But in reality, Exe2 is started by Exe1 using CreatePorcess(). This is when I get "Not Supported" msg. Following is the code from Exe1 that starts Exe2.. function CreateProcessAndReturn(const AppName: string; ShowState: Integer): THandle; var ProcessInfo: TProcessInformation; StartupInfo: TStartupInfo; begin FillChar(StartupInfo, SizeOf(TStartupInfo), #0); with StartupInfo do begin cb := SizeOf(TStartupInfo); dwFlags := STARTF_USESHOWWINDOW; wShowWindow := ShowState; end; if CreateProcess(nil, PChar(AppName), nil, nil, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then Result := ProcessInfo.hProcess else Result := 0; end; Any ideas on how to fix it? Thank you in advance.
  10. NamoRamana

    COM+ Monitor statistics

    Thanks for the pointer on WMI classes. There are few COM and DCOM related classes like Win32_ClassicCOMClass, Win32_COMClass, Win32_DCOMApplication. etc, but couldn't find anything that gives COM statistics. Appreciate your help.
  11. NamoRamana

    COM+ Monitor statistics

    Is there anyway in Delphi to get COM+ statistics (Highlighted part in the Image below) ? I looked into COMAdminCatalogObejct, I don't think it has methods/properties to return the statistics. The closest API I found is: https://www.codeproject.com/Articles/12264/Comonitor-A-COM-Monitor
  12. NamoRamana

    Olevariant and memory leak

    Update: Thank you very much, @pyscripter for pointing missing inheritance. We modified the code accordingly and tested in both the versions... In Rio, we still see the memory increase.. But in 10.4.1, it did not. Thank you Anders and Dave as well. In conclusion, we are planning to upgrade our code base to 10.4.1.
  13. NamoRamana

    Olevariant and memory leak

    My bad.. Even when you take these 2 functions out and comment out all OutputDebugString() from Initialize and Destroy, it still increases the memory in Rio.. We are currently testing in 10.4.1.. Will post the update about that later. COMBug.zip
  14. NamoRamana

    Olevariant and memory leak

    Ok, Guys.. took me a while to come up with reproducible code.. But its attached here. You will see that with each click on a button, the memory increases. We also ran the same code under D 10.4.1 and unfortunately, the behavior is the same -- it keeps on increasing the memory. COMBug.zip
  15. NamoRamana

    Olevariant and memory leak

    Ok.. I tried passing the OleVariant by ref. That didn't work. I also tried assigning a temp variable "UnAssigned". That didn't work either. Now I found the following QC: https://quality.embarcadero.com/browse/RSP-14749. This mentions the almost similar situation I have. I tried to look around in System.Win.ComObj to find DispatchInvoke(). In it, it has try..finally, which calls FinalizeDispatchInvokeArgs() which does the clean up. I think, FinalizeDispatchInvokeArgs() has the same code mention in comment in QC: https://quality.embarcadero.com/browse/RSP-9819 Can a Delphi Guru enlighten me with simplicity here -- whether the leak mentioned above is caused by these delphi units? Coz code in System.Win.ComObj and System.Variants are too hot for me... 🔥
×