Welcome, Guest
Username: Password: Remember me
Components and Libraries for Networking Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Windows API: Where is TNetResource? 6 years 4 months ago #11815

  • Graham
  • Graham's Avatar Topic Author
  • Visitor
  • Visitor
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.

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

Last edit: by Graham.

Windows API: Where is TNetResource? 6 years 4 months ago #11817

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
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"

PilotLogic Architect and Core Programmer
Attachments:

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

Last edit: by Sternas Stefanos.

Windows API: Where is TNetResource? 6 years 4 months ago #11818

  • Graham
  • Graham's Avatar Topic Author
  • Visitor
  • Visitor
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.

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

Last edit: by Graham.

Windows API: Where is TNetResource? 6 years 4 months ago #11819

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Sir
my suggestion is to put "jwawinnetwk" unit in your app uses
and try your app
PilotLogic Architect and Core Programmer

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

  • Page:
  • 1