Stephan
August 4th, 1999, 12:41 PM
Hi
My app is copying files from a cd to a selected harddrive, and is then creating icons on the desktop and the start menu. Everything is working fine on Win 98 and some NT machines, but under Win 95 it fails because the SHELL32.DLL is old.
So far so good, I thought.
All I need to do is to replace the existing DLL with the new one.
The code below will show how I have tried to implement it.
InstallSharedFile("SHELL32.DLL",pszTo,pszFrom);
// Call SHFileOperation()
ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
shfo.hwnd = hDlg;
shfo.wFunc = wFunc;
// shfo.lpszProgressTitle = pszTitle;
shfo.fFlags = static_cast<FILEOP_FLAGS>(wFlags);
shfo.pTo = pszTo;
shfo.pFrom = pszFrom;
int iRC = SHFileOperation(&shfo);
if(shfo.fAnyOperationsAborted)
{
Msg("Aborted!");
return;
}
// Display the result of the operation
SPB_SystemMessage(iRC);
//Lets create our company icon on the Startup Menu
SHCreateSystemShortcut(__TEXT("drs.lnk"),CSIDL_STARTMENU,__TEXT("c:\\codesign\\drswin\\win32-~1\\bin\\drs.exe"));
//Lets create an Shortcut on the Desktop too
SHCreateSystemShortcut(__TEXT("drs.lnk"),CSIDL_DESKTOP,__TEXT("c:\\codesign\\drswin\\win32-~1\\bin\\drs.exe"));
DWORD InstallSharedFile(LPSTR szFileToInstall,LPSTR szDirectory,LPSTR From)
{
TCHAR sWinDir[MAX_PATH]; //Holds the Windows Directory.
TCHAR sCurDir[MAX_PATH]; //Returns path to preexisting file.
TCHAR sDestDir[MAX_PATH]; //Returns recommended path for file.
TCHAR sTmpFile[MAX_PATH]; //Buffer for temp file name.
UINT uCurLen = _MAX_PATH; //Holds the length of sCurDir.
UINT uDestLen = _MAX_PATH; //Holds the length of sDestDir.
UINT uTmpLen = _MAX_PATH; //Holds the length of the sTmpFile.
DWORD dwStatus; //Return value from the function
//TCHAR extension[MAX_PATH] = "codesign"; //Points to install directory on the cd.
//lstrcat(szDirectory,extension);
//Get the windows Directory.
GetWindowsDirectory(sWinDir,sizeof(sWinDir));
//Find out if the file exists and if so, where.
dwStatus = VerFindFile(0,szFileToInstall,sWinDir,szDirectory,sCurDir,&uCurLen,sDestDir,&uDestLen);
if(dwStatus == VFF_FILEINUSE)
Msg("This file is in use, close all apllications and try again.");
else if(dwStatus == VFF_CURNEDEST)
Msg("This file do not exist in destination");
else if(dwStatus == VFF_BUFFTOOSMALL)
Msg("Buffer is too small");
else
dwStatus = VerInstallFile(0,szFileToInstall,szFileToInstall,From,sDestDir,sCurDir,sTmpFile,&uTmpLen);
return(dwStatus);
}
I still have a big problem with the above, because when I specify the flag VFFF_ISSHAREDFILE flag, the
system tells me it cannot do anything because the file is being shared.
Can anyone suggest how I can succesfully install the new DLL on any system under program control, so that my program will be enabled to do its work.
Regards
Stephan
My app is copying files from a cd to a selected harddrive, and is then creating icons on the desktop and the start menu. Everything is working fine on Win 98 and some NT machines, but under Win 95 it fails because the SHELL32.DLL is old.
So far so good, I thought.
All I need to do is to replace the existing DLL with the new one.
The code below will show how I have tried to implement it.
InstallSharedFile("SHELL32.DLL",pszTo,pszFrom);
// Call SHFileOperation()
ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
shfo.hwnd = hDlg;
shfo.wFunc = wFunc;
// shfo.lpszProgressTitle = pszTitle;
shfo.fFlags = static_cast<FILEOP_FLAGS>(wFlags);
shfo.pTo = pszTo;
shfo.pFrom = pszFrom;
int iRC = SHFileOperation(&shfo);
if(shfo.fAnyOperationsAborted)
{
Msg("Aborted!");
return;
}
// Display the result of the operation
SPB_SystemMessage(iRC);
//Lets create our company icon on the Startup Menu
SHCreateSystemShortcut(__TEXT("drs.lnk"),CSIDL_STARTMENU,__TEXT("c:\\codesign\\drswin\\win32-~1\\bin\\drs.exe"));
//Lets create an Shortcut on the Desktop too
SHCreateSystemShortcut(__TEXT("drs.lnk"),CSIDL_DESKTOP,__TEXT("c:\\codesign\\drswin\\win32-~1\\bin\\drs.exe"));
DWORD InstallSharedFile(LPSTR szFileToInstall,LPSTR szDirectory,LPSTR From)
{
TCHAR sWinDir[MAX_PATH]; //Holds the Windows Directory.
TCHAR sCurDir[MAX_PATH]; //Returns path to preexisting file.
TCHAR sDestDir[MAX_PATH]; //Returns recommended path for file.
TCHAR sTmpFile[MAX_PATH]; //Buffer for temp file name.
UINT uCurLen = _MAX_PATH; //Holds the length of sCurDir.
UINT uDestLen = _MAX_PATH; //Holds the length of sDestDir.
UINT uTmpLen = _MAX_PATH; //Holds the length of the sTmpFile.
DWORD dwStatus; //Return value from the function
//TCHAR extension[MAX_PATH] = "codesign"; //Points to install directory on the cd.
//lstrcat(szDirectory,extension);
//Get the windows Directory.
GetWindowsDirectory(sWinDir,sizeof(sWinDir));
//Find out if the file exists and if so, where.
dwStatus = VerFindFile(0,szFileToInstall,sWinDir,szDirectory,sCurDir,&uCurLen,sDestDir,&uDestLen);
if(dwStatus == VFF_FILEINUSE)
Msg("This file is in use, close all apllications and try again.");
else if(dwStatus == VFF_CURNEDEST)
Msg("This file do not exist in destination");
else if(dwStatus == VFF_BUFFTOOSMALL)
Msg("Buffer is too small");
else
dwStatus = VerInstallFile(0,szFileToInstall,szFileToInstall,From,sDestDir,sCurDir,sTmpFile,&uTmpLen);
return(dwStatus);
}
I still have a big problem with the above, because when I specify the flag VFFF_ISSHAREDFILE flag, the
system tells me it cannot do anything because the file is being shared.
Can anyone suggest how I can succesfully install the new DLL on any system under program control, so that my program will be enabled to do its work.
Regards
Stephan