In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Application:cDirectory Windows 8
Application:cDirectory Windows 8
Hello Xailers,
When I try to execute my program with admin rights from a network place it returns a different Application:cDirectory...
eg.: Without admin rights it returns F:TestsExample
With admin rights it returns TestesExample or
linuxSistemaTestsExample
Is this an error? How can I make it return F:TestsExample when executed with admin rights?
Thanks in advance,
Juliano
When I try to execute my program with admin rights from a network place it returns a different Application:cDirectory...
eg.: Without admin rights it returns F:TestsExample
With admin rights it returns TestesExample or
linuxSistemaTestsExample
Is this an error? How can I make it return F:TestsExample when executed with admin rights?
Thanks in advance,
Juliano
- ignacio
- Site Admin
- Mensajes: 9253
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Application:cDirectory Windows 8
emeasoft escribió el mar, 22 octubre 2013 19:14Hello Xailers,
When I try to execute my program with admin rights from a network place it returns a different Application:cDirectory...
eg.: Without admin rights it returns F:TestsExample
With admin rights it returns TestesExample or
linuxSistemaTestsExample
Is this an error? How can I make it return F:TestsExample when executed with admin rights?
Thanks in advance,
Juliano
Xailer uses the API function GetModuleFileName(). Check this link for further information:
http://msdn.microsoft.com/en-us/library ... sktop/ms68 3197(v=vs.85).aspx
Regards,
When I try to execute my program with admin rights from a network place it returns a different Application:cDirectory...
eg.: Without admin rights it returns F:TestsExample
With admin rights it returns TestesExample or
linuxSistemaTestsExample
Is this an error? How can I make it return F:TestsExample when executed with admin rights?
Thanks in advance,
Juliano
Xailer uses the API function GetModuleFileName(). Check this link for further information:
http://msdn.microsoft.com/en-us/library ... sktop/ms68 3197(v=vs.85).aspx
Regards,
Application:cDirectory Windows 8
Hello Ignacio,
So, cant I get a not UNC patch when executing a program as admin on a network from a windows 8 pc?
Will it always return the UNC path? eg.: computeruserdir instead of X:dir
TIA,
Juliano
So, cant I get a not UNC patch when executing a program as admin on a network from a windows 8 pc?
Will it always return the UNC path? eg.: computeruserdir instead of X:dir
TIA,
Juliano
- ignacio
- Site Admin
- Mensajes: 9253
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Application:cDirectory Windows 8
emeasoft escribió el mié, 30 octubre 2013 13:36Hello Ignacio,
So, cant I get a not UNC patch when executing a program as admin on a network from a windows 8 pc?
Will it always return the UNC path? eg.: computeruserdir instead of X:dir
TIA,
Juliano
I believe that is not possible since many drive mapping can have the same path. But I really do not know. That is a specific OS issue.
Regards
So, cant I get a not UNC patch when executing a program as admin on a network from a windows 8 pc?
Will it always return the UNC path? eg.: computeruserdir instead of X:dir
TIA,
Juliano
I believe that is not possible since many drive mapping can have the same path. But I really do not know. That is a specific OS issue.
Regards
- orangesocks
- Mensajes: 59
- Registrado: Jue May 05, 2011 3:28 pm
Application:cDirectory Windows 8
Hello Juliano,
You can try with this function.
I use it with my console apps. On Win7 it works OK but I don't have Win8 so I don't know if it fails.
FUNCTION GetAppPath()
LOCAL cFileName AS CHAR
cFileName := hb_argv( 0 )
RETURN Left( cFileName, RAt( "", cFileName ) )
HTH Regards, Giuseppe
You can try with this function.
I use it with my console apps. On Win7 it works OK but I don't have Win8 so I don't know if it fails.
FUNCTION GetAppPath()
LOCAL cFileName AS CHAR
cFileName := hb_argv( 0 )
RETURN Left( cFileName, RAt( "", cFileName ) )
HTH Regards, Giuseppe
Application:cDirectory Windows 8
Hello Ignacio and Giuseppe, thanks for your help!
Giuseppe, this function did not work on windows 8... it still returns the unc path.
Any of you know if there is a way to translate the unc path to a path with drive letter?
TIA,
Juliano
Giuseppe, this function did not work on windows 8... it still returns the unc path.
Any of you know if there is a way to translate the unc path to a path with drive letter?
TIA,
Juliano
Application:cDirectory Windows 8
Juliano,
See below.
Maybe not so good code, but working
Regards, Oleg
func UNC2Mapped(cUncPath)
local cMapped, cUnc, i
cMapped:=''
for i:=asc('F') to asc('Z')
cUnc:=Mapped2Unc(chr(i)+':')
if !empty(cUnc).and.cUncPath=cUnc
cMapped:=stuff(cUncPath,1,len(cUnc),chr(i)+':')
exit
endif
next
return cMapped
....
#include "windows.h"
#include "hbapi.h"
HB_FUNC( MAPPED2UNC ){
char *path = hb_parc(1), *unc;
UNIVERSAL_NAME_INFO *puinfo;
char buf2[300];
DWORD size=300;
unc = hb_xgrab(254);
if (!path || !unc){
hb_ret();
hb_xfree(unc);
return;
}
//check its valid
if (GetFileAttributes(path) == 0xffffffff){
hb_ret();
hb_xfree(unc);
return;
}
//if already unc then just copy it over
if (path[0] == '' && path[1] == '') {
strcpy(unc,path);
hb_retc(unc);
hb_xfree(unc);
return;
}
//we need to find out if its a network drive
//if so we need to get the UNC path cos the
if (WNetGetUniversalName(path, UNIVERSAL_NAME_INFO_LEVEL, buf2, &size)
== NO_ERROR)
{
//it is a network drive so lets get the UNC path
puinfo = (UNIVERSAL_NAME_INFO*)buf2;
strcpy(unc,puinfo->lpUniversalName);
hb_retc(unc);
hb_xfree(unc);
return;
}
hb_ret();
hb_xfree(unc);
return;
}
....
See below.
Maybe not so good code, but working
Regards, Oleg
func UNC2Mapped(cUncPath)
local cMapped, cUnc, i
cMapped:=''
for i:=asc('F') to asc('Z')
cUnc:=Mapped2Unc(chr(i)+':')
if !empty(cUnc).and.cUncPath=cUnc
cMapped:=stuff(cUncPath,1,len(cUnc),chr(i)+':')
exit
endif
next
return cMapped
....
#include "windows.h"
#include "hbapi.h"
HB_FUNC( MAPPED2UNC ){
char *path = hb_parc(1), *unc;
UNIVERSAL_NAME_INFO *puinfo;
char buf2[300];
DWORD size=300;
unc = hb_xgrab(254);
if (!path || !unc){
hb_ret();
hb_xfree(unc);
return;
}
//check its valid
if (GetFileAttributes(path) == 0xffffffff){
hb_ret();
hb_xfree(unc);
return;
}
//if already unc then just copy it over
if (path[0] == '' && path[1] == '') {
strcpy(unc,path);
hb_retc(unc);
hb_xfree(unc);
return;
}
//we need to find out if its a network drive
//if so we need to get the UNC path cos the
if (WNetGetUniversalName(path, UNIVERSAL_NAME_INFO_LEVEL, buf2, &size)
== NO_ERROR)
{
//it is a network drive so lets get the UNC path
puinfo = (UNIVERSAL_NAME_INFO*)buf2;
strcpy(unc,puinfo->lpUniversalName);
hb_retc(unc);
hb_xfree(unc);
return;
}
hb_ret();
hb_xfree(unc);
return;
}
....
Application:cDirectory Windows 8
This code works in case:
only one drive letter mapped to one UNC path
only one drive letter mapped to one UNC path
- orangesocks
- Mensajes: 59
- Registrado: Jue May 05, 2011 3:28 pm
Application:cDirectory Windows 8
Hello Juliano,
You can also use the registry. See attached example.
HTH Giuseppe
Attached files TestUNCToLocalPath.zip (3.8 KB)Â
You can also use the registry. See attached example.
HTH Giuseppe
Attached files TestUNCToLocalPath.zip (3.8 KB)Â
Application:cDirectory Windows 8
Many Thanks for the help Giuseppe and Oleg!
It worked very well!
Regards,
Juliano
It worked very well!
Regards,
Juliano
Application:cDirectory Windows 8
Hello,
We are having the following problem with Windows 8 when running as administrator on a server on the network:
--------------------------------------------
Windows XP e Windows 7:
Application:cDirectory = F:XAILER
Application:CurrentDrive() = F:
HB_Curdrive() = F
CurDir() = XAILER
--------------------------------------------
Windows 8:
Application:cDirectory = linuxxailer
Application:CurrentDrive() = A:
HB_Curdrive() = A
CurDir() = linuxxailer
If we use the LEN(Directory("F:XAILER*.*")) it returns 0.
--------------------------------------------
We understand that the returns should be the same, regardless the OS.
Thanks
Mário Angelini
We are having the following problem with Windows 8 when running as administrator on a server on the network:
--------------------------------------------
Windows XP e Windows 7:
Application:cDirectory = F:XAILER
Application:CurrentDrive() = F:
HB_Curdrive() = F
CurDir() = XAILER
--------------------------------------------
Windows 8:
Application:cDirectory = linuxxailer
Application:CurrentDrive() = A:
HB_Curdrive() = A
CurDir() = linuxxailer
If we use the LEN(Directory("F:XAILER*.*")) it returns 0.
--------------------------------------------
We understand that the returns should be the same, regardless the OS.
Thanks
Mário Angelini
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
> If we use the LEN(Directory("F:XAILER*.*")) it returns 0.
¿Doesn't it work just using Len( Directory( Application:cDirectory ) )?
AFAIK the Harbour file system should manage UNC paths as it uses the OS
native file system.
Regards,
José Lalín
> If we use the LEN(Directory("F:XAILER*.*")) it returns 0.
¿Doesn't it work just using Len( Directory( Application:cDirectory ) )?
AFAIK the Harbour file system should manage UNC paths as it uses the OS
native file system.
Regards,
José Lalín
Application:cDirectory Windows 8
Lalin
Len( Directory( Application:cDirectory ) ) retorna correto, mas precisamos em muitas
rotinas saber qual o Application:CurrentDrive() ou HB_Curdrive() e está retornando
diferente do Win 7/XP.
Entendemos que deverá retornar sempre a mesma coisa, independente do sistema operacional.
Mário Angelini
Len( Directory( Application:cDirectory ) ) retorna correto, mas precisamos em muitas
rotinas saber qual o Application:CurrentDrive() ou HB_Curdrive() e está retornando
diferente do Win 7/XP.
Entendemos que deverá retornar sempre a mesma coisa, independente do sistema operacional.
Mário Angelini
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
sorry, I didn't understood the problem at first read. Maybe these Harbour
functions can help you:
hb_ProgName()
hb_DirBase()
hb_CWD()
Regards,
José Lalín
sorry, I didn't understood the problem at first read. Maybe these Harbour
functions can help you:
hb_ProgName()
hb_DirBase()
hb_CWD()
Regards,
José Lalín
Application:cDirectory Windows 8
Lalin,
Não resolveu.
Continua com o mesmo problema.
Abraços.
Mário
Não resolveu.
Continua com o mesmo problema.
Abraços.
Mário
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
¿can you tell me what shows this code in both W7 and W8?
MsgInfo( Application:cDirectory + CRLF + Application:cFilename )
Regards,
José Lalín
¿can you tell me what shows this code in both W7 and W8?
MsgInfo( Application:cDirectory + CRLF + Application:cFilename )
Regards,
José Lalín
Application:cDirectory Windows 8
Lalin:
Win 7:
F:BACKUP
F:BACKUPTESTE.exe
Win 8:
linuxsistemaBACKUP
linuxsistemaBACKUPTESTE.exe
Regards
Mário Angelini
Win 7:
F:BACKUP
F:BACKUPTESTE.exe
Win 8:
linuxsistemaBACKUP
linuxsistemaBACKUPTESTE.exe
Regards
Mário Angelini
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
now can you show me some code to see what you want to do?
Regards,
José Lalín
now can you show me some code to see what you want to do?
Regards,
José Lalín
Application:cDirectory Windows 8
Hello,
Eg:
VolSerial("F:")
We have many routines that use:
Application:cDirectory
Application:CurrentDrive()
HB_Curdrive()
CurDir(
Our users that use network, have terminals with Win XP/7/8, all together on the network.
The return of this functions should be all the same.
Eg.:
An application on a terminal with windows 7 returns:
Application:CurrentDrive() = F:
HB_Curdrive() = F
--------------------------------------------
The same application on windows 8 returns:
Application:CurrentDrive() = A:
HB_Curdrive() = A
It is visible that this is not right.
Regards
Mário Angelini
Eg:
VolSerial("F:")
We have many routines that use:
Application:cDirectory
Application:CurrentDrive()
HB_Curdrive()
CurDir(
Our users that use network, have terminals with Win XP/7/8, all together on the network.
The return of this functions should be all the same.
Eg.:
An application on a terminal with windows 7 returns:
Application:CurrentDrive() = F:
HB_Curdrive() = F
--------------------------------------------
The same application on windows 8 returns:
Application:CurrentDrive() = A:
HB_Curdrive() = A
It is visible that this is not right.
Regards
Mário Angelini
Application:cDirectory Windows 8
WITH OBJECT TRegistry():Create()
//Desativa UAC - Requer reinicialização do equipamento
//Disable UAC - Requires restart of equipment
:Root:=HKEY_LOCAL_MACHINE
IF :OpenKey("Software")=0
:CreateKey("Microsoft","Software")
:CreateKey("Windows","Microsoft")
:CreateKey("CurrentVersion","Windows")
:CreateKey("Policies","CurrentVersion")
:CreateKey("System","Policies")
:CloseKey(.T.)
IF :OpenKey("SoftwareMicrosoftWindowsCurrentVersionPoliciesSystem") = 0
IF :GetNumeric( "EnableLUA" )=1
:SetNumeric("EnableLUA",0)
ENDIF
ENDIF
:CloseKey(.T.)
ENDIF
:CloseKey(.T.)
:Flush(.T.)
:Destroy(.T.)
END
Resolvido / Resuelto / resolved
Regards
Mário Angelini
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
> It is visible that this is not right.
From an OS point of view the last is the correct. The UNC paths should
(and must) hide the real path in terms of security.
Anyhow, I found some info explaining how to do it in Win8. I will try to
find some spare time tonight to do it.
Regards,
José Lalín
> It is visible that this is not right.
From an OS point of view the last is the correct. The UNC paths should
(and must) hide the real path in terms of security.
Anyhow, I found some info explaining how to do it in Win8. I will try to
find some spare time tonight to do it.
Regards,
José Lalín
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
many network administrators disable the access to the registry so be
careful and check that function runs correctly in every system.
Regards,
José Lalín
many network administrators disable the access to the registry so be
careful and check that function runs correctly in every system.
Regards,
José Lalín
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
the attached obj includes a function to convert an UNC path to a local path.
UNCToPath( cUNCPath, @nError ) --> cLocalPath
* cUNCPath: the UNC path to convert
* nError: error code (Optional).
-1 internal error
0 success
any other value: OS code
Example:
LOCAL nErr := 0
MsgInfo( UNCToPath( Application:cDirectory ) )
MsgInfo( UNCToPath( Application:cDirectory, @nErr ) )
IF nErr != 0
MsgSysError( nErr )
ENDIF
I could not test it in a real scenario yet. Let me know if it works.
Regards,
José Lalín
--
the attached obj includes a function to convert an UNC path to a local path.
UNCToPath( cUNCPath, @nError ) --> cLocalPath
* cUNCPath: the UNC path to convert
* nError: error code (Optional).
-1 internal error
0 success
any other value: OS code
Example:
LOCAL nErr := 0
MsgInfo( UNCToPath( Application:cDirectory ) )
MsgInfo( UNCToPath( Application:cDirectory, @nErr ) )
IF nErr != 0
MsgSysError( nErr )
ENDIF
I could not test it in a real scenario yet. Let me know if it works.
Regards,
José Lalín
--
-
- Mensajes: 291
- Registrado: Jue Ene 31, 2013 1:10 pm
Application:cDirectory Windows 8
Mário,
I see it while writing this reply.
Regards,
José Lalín
I see it while writing this reply.
Regards,
José Lalín