Hello.
When I make API Control Extension (dll) ref. with another dll (c++),
put them in same folder (WinCC_OA_Proj\\bin\\) and call API function in API Control Extension, then dll can't find referenced dll.
But, put referenced dll in system32 folder, then API Control Extension works well.
That is,
WinCC OA Project -> WinCC_OA_Proj
API Control Extension -> MyCtrlExt.dll
referenced dll -> ref.dll
file location -> D:\\WinCC_OA_Proj\\bin\\
message -> missing ref.dll
So, my question is:
1. how can get actual file path of API Control Extension path (in above case, I want get "D:\\WinCC_OA_Proj\\bin\\MyCtrlExt.dll")
2. or how can use API Control Extension with another dll in same folder.
How can I know dll file path in C++ API Control Extension
- kiducduc
- Posts:7
- Joined: Tue Nov 28, 2017 3:18 am
How can I know dll file path in C++ API Control Extension
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How can I know dll file path in C++ API Control Extension
1a) In CTRL: getPath(BIN_REL_PATH, "MyCtrlExt.dll")
1b) In C++ API: PVSSFileSys::fileExists(Resources::getProjBinDir, "MyCtrlExt.dll")
1) How does knowing the actual path of the control extension help you?
2) The system32 directory is included in the 'PATH' environment variable, that is why it works if the referenced dll is there. So adding the drectory containing the referenced dll to the 'PATH' variable, before the control extension is loaded, should work.
In case the referenced dll is delay-loaded or dynamically loaded also the control extension itself could modify the 'PATH' variable before the referenced dll is actually loaded.
1b) In C++ API: PVSSFileSys::fileExists(Resources::getProjBinDir, "MyCtrlExt.dll")
1) How does knowing the actual path of the control extension help you?
2) The system32 directory is included in the 'PATH' environment variable, that is why it works if the referenced dll is there. So adding the drectory containing the referenced dll to the 'PATH' variable, before the control extension is loaded, should work.
In case the referenced dll is delay-loaded or dynamically loaded also the control extension itself could modify the 'PATH' variable before the referenced dll is actually loaded.
- kiducduc
- Posts:7
- Joined: Tue Nov 28, 2017 3:18 am
Re: How can I know dll file path in C++ API Control Extension
Gertjan van Schijndel wrote:
So, the way of 1b) works perfect in my dll.
Thank you.
With actual path, I was trying to use "LoadLibrary" function to import dll or register environment variable.1a) In CTRL: getPath(BIN_REL_PATH, "MyCtrlExt.dll")
1b) In C++ API: PVSSFileSys::fileExists(Resources::getProjBinDir, "MyCtrlExt.dll")
1) How does knowing the actual path of the control extension help you?
So, the way of 1b) works perfect in my dll.
Thank you.
- mberdich
- Posts:2
- Joined: Wed May 23, 2018 4:14 pm
Re: How can I know dll file path in C++ API Control Extension
Hi Gertjan, Hi Jon Gyun
we need help:
- how could we add the dll path to the PATH variable via ctrl ext?
- do you have an example for us?
thanks a lot!
we need help:
- how could we add the dll path to the PATH variable via ctrl ext?
- do you have an example for us?
thanks a lot!
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How can I know dll file path in C++ API Control Extension
In C++ API an environment variable can be set with 'NoPosix::setenv'. Setting the PATH environment variable only helps if the control extension is actually loaded, so it does not help to resolve finding statically linked libraries.
- mberdich
- Posts:2
- Joined: Wed May 23, 2018 4:14 pm
Re: How can I know dll file path in C++ API Control Extension
Hi Gertjan,
I tried following:
1) Add /DELAYLOAD:"test.dll" to the compiler.
2) In the ctrl extension execute function i add the absolute path of the dll
tot he PATH variable
3) Now the ui does not crash while starting the ui manager but if i execute
the function where the external dll is used the ui manager crashes without a
message
What do i wrong?
best regards,
mario
I tried following:
1) Add /DELAYLOAD:"test.dll" to the compiler.
2) In the ctrl extension execute function i add the absolute path of the dll
tot he PATH variable
3) Now the ui does not crash while starting the ui manager but if i execute
the function where the external dll is used the ui manager crashes without a
message
What do i wrong?
best regards,
mario
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: How can I know dll file path in C++ API Control Extension
Perhaps the path must be set before the control extension (dll) is loaded also in case of delayed loading.
But normally if a control extension is tried to load, which is missing dependencies, the UI does not crash. Only a 'version is not compatible' error is thrown. Maybe there is something else wrong in your control extension, causing the crash.
But normally if a control extension is tried to load, which is missing dependencies, the UI does not crash. Only a 'version is not compatible' error is thrown. Maybe there is something else wrong in your control extension, causing the crash.
- CyaNn
- Posts:97
- Joined: Tue Nov 23, 2010 9:48 am
Re: How can I know dll file path in C++ API Control Extension
Personnaly, I use some good old C++ windows tools to find my linkage errors :
- sysinternal dependency walker
- sysinternals listdlls
all are available here :
https://docs.microsoft.com/en-us/sysint ... downloads/
also another usefull tool : WinDbg
I hope it help
- sysinternal dependency walker
- sysinternals listdlls
all are available here :
https://docs.microsoft.com/en-us/sysint ... downloads/
also another usefull tool : WinDbg
I hope it help