c++builder - Alternative to symlink in C++ Builder -


i'm trying integrate c code written unix in c++ builder. part of code using function symlink :

if(!fname || (use_real_copy ? real_copy(path, fname) : symlink(path, fname)) 

i don't know how replace works in c++ builder windows 64 bits, i've found functions createsymboliclinkw , createsymboliclinka seem equivalent windows c++ builder can't find them.

do have idea of how can around problem?

thank you.

createsymboliclink() declared in winbase.h, #include'd windows.h, #include'd vcl.h in vcl-based projects. if not creating vcl project, make sure have #include <windows.h> statement in code. either way, make sure _win32_winnt defined @ least 0x0600 (vista+).

if compiler still complains createsymboliclink() undefined must using old version of c++builder (createsymboliclink() added c++builder's copy of winbase.h in c++builder 2007), in case have declare createsymboliclink() manually in own code, eg:

#define symbolic_link_flag_directory            (0x1)  #define valid_symbolic_link_flags  symbolic_link_flag_directory // & whatever other flags think of!  winbaseapi boolean apientry createsymboliclinka (     __in lpcstr lpsymlinkfilename,     __in lpcstr lptargetfilename,     __in dword dwflags     ); winbaseapi boolean apientry createsymboliclinkw (     __in lpcwstr lpsymlinkfilename,     __in lpcwstr lptargetfilename,     __in dword dwflags     ); #ifdef unicode #define createsymboliclink  createsymboliclinkw #else #define createsymboliclink  createsymboliclinka #endif // !unicode 

but have problem tackle - version of c++builder not have createsymboliclinka , createsymboliclinkw symbols in copy of kernel32.lib linking exported functions in kernel32.dll. have create new .lib import library modern kernel32.dll includes symbols, , add project. @ point, easier dynamically load createsymboliclink() @ runtime using getprocaddress() instead:

typedef boolean (apientry *lpfn_csl)(lpctstr, lpctstr, dword);  lpfn_csl lpcreatesymboliclink = (lpfn_csl) getprocaddress(getmodulehandle(text("kernel32")),     #ifdef unicode     "createsymboliclinkw"     #else     "createsymboliclinka"     #endif ); if (lpcreatesymboliclink) {     // use lpcreatesymboliclink(...) needed... } 

which allow code run on xp , earlier (if needed), since createsymboliclink() added in vista.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -