winapi - How to set current directory while working with an OLE Automation Server -


i trying create ole exe server's instance through createdispatch call apparently fails because current directory not correct. error "server initialization failed". debugged createdispatch code , found out 3 things.

  1. cocreateinstance //in case succeeds
  2. olerun //this fails in case error 'server execution failed'
  3. queryinterface idispatch

i tried launch process through createprocess fails if don't provide correct currentdirectory in 8th argument means in case currentdirectory not correct , have provide working.

i know parent's currentdirectory passed on when parent trying spawn process. so, tried changing parent's currentdirectory appropriate directory via setcurrentdirectory api call. works in case of createprocess doesn't work in case of createdispatch giving me same error , failing on same olerun call inside.

does have idea how can pass on currentdirectory createdispatch? or there workaround?

if need have currect directory set application directory, shoul djust thi sin "main" of program. can getmodulefilename , use splitpath directory , tehn call setcurrentdirectory.

#include <windows.h> #include <stdio.h> #include <tchar.h>  int _tmain() {     tchar szdrive[_max_drive];     tchar szpath[_max_path];     tchar szname[_max_fname];     tchar szext[_max_ext];     tchar szmodname[max_path];     getmodulefilename(null, szmodname, max_path);     _tsplitpath(szmodname, szdrive, szpath, szname, szext);      tchar szappdir[max_path];     _tcscpy_s(szappdir, szdrive);     _tcscat_s(szappdir, szpath);     setcurrentdirectory(szappdir);     _tprintf(szappdir); } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -