Forum

× Components and Libraries for Networking Development, discussions, problems and suggestions

Question Windows API: Where is TNetResource?

  • Graham
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
4 months 4 days ago - 4 months 4 days ago #11815 by Graham
Windows API: Where is TNetResource? was created by Graham
Hi,
I have an application that was written for/in Delphi about a year ago, and this still compiles just fine. I have since moved a part of it into a new application under Code Typhon, however I cannot connect or use the appropriate Windows API. The original program compiles just fine under Delphi, using the Windows unit. Although this same unit appears to exist under Code Typhon, it fails to work when listed under uses.

I have done quite some research through Lazarus web pages and online forums, and from what I understand (based on this page: wiki.freepascal.org/Windows_API_units , and this page wiki.freepascal.org/Winunits-Base ) it appears that possibly the Windows API's have been split out into various units. Unless I am just confused, however there appears to be zero online documentation in this regard for either Code Typhon or Lazarus.

My program is complaining that CONNECT_TEMPORARY (under WNetAddConnection2) identifier is not found, though this clearly works under the Delphi/Windows unit that covers the necessary Windows API. Predefined constants such as CONNECT_TEMPORARY are also not found, yet I can navigate to them in Delphi (again, under Windows unit)

So my question is, what unit am I missing under uses (if that's the problem) or should I be using an alternative to the apparently non existent WNetAddConnection2 procedure, and how are we expected to find these units for a given API? IE documentation.

Thanks.
Last edit: 4 months 4 days ago by Graham.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 months 4 days ago - 4 months 4 days ago #11817 by Sternas Stefanos
Replied by Sternas Stefanos on topic Windows API: Where is TNetResource?
Sir
you can find both (TNetResource identifier and CONNECT_TEMPORARY constant)
in
C:\codetyphon\fpcsrc\packages\winunits-jedi\src\jwawinnetwk.pas

CodeTyphon it's a BIG open source Programming Studio
online documentation it's NOT so simple at this level.

Please try to use
CTCenter => "Find Files Tool"


CodeTyphon Architect and Programmer
Attachments:
Last edit: 4 months 4 days ago by Sternas Stefanos.

Please Log in or Create an account to join the conversation.

  • Graham
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
4 months 3 days ago - 4 months 3 days ago #11818 by Graham
Replied by Graham on topic Windows API: Where is TNetResource?
Hi Sternas,

firstly, thank you for your assistance. I'm still a somewhat green user of Delphi/CT, so appreciate your help. I'll try using the tool you mentioned as I'm sure that's very useful too. I seem to have found that although WNetAddConnection2 is well supported under Delphi, the API wrapper under CT appears to be missing most of the constants as listed by Microsoft ( msdn.microsoft.com/en-us/library/windows...385413(v=vs.85).aspx ). In fact the only one I can find listed in the CT windows wrapper is CONNECT_UPDATE_PROFILE. When I insert this into my code and delete CONNECT_TEMPORARY, the program compiles just fine (though of course my program is not working as expected).

I tried adding CONNECT_TEMPORARY under defines.inc (part of API wrapper in CT) but when compiling, CT doesn't find it. Being inexperienced, I also don't know how the wrapper makes the connection between WNetAddConnection2 (redef.inc) and CONNECT_UPDATE_PROFILE (defines.inc), but that's a Pascal programming problem on my part, and not a CT issue.

The bottom line is it appears that WNetAddConnection2 is missing many constant definitions as prescribed by Microsoft. I wouldn't mind fixing the problem/files myself if I knew where to go/what to do.

I see you also say the CONNECT_TEMPORARY constant is available in jwawinnetwk.pas but then shouldn't this be picked up when using the Windows unit? I would be very wary of throwing a random unit into my code, in case this constant (by coincidence) has the same name, but is referring to something else entirely different. Just my humble opinion. The example you have given me is (I think) a good example of this. Using the tool you mentioned, I have looked in the jwawinnetwk.pas file and CONNECT_TEMPORARY is shown to have a value of 4 (hex) whereas Microsoft say the value should be 8.
Last edit: 4 months 3 days ago by Graham.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 months 3 days ago #11819 by Sternas Stefanos
Replied by Sternas Stefanos on topic Windows API: Where is TNetResource?
Sir
my suggestion is to put "jwawinnetwk" unit in your app uses
and try your app

CodeTyphon Architect and Programmer

Please Log in or Create an account to join the conversation.