mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
Fixed ZuneHost dependency issues...
... by copying the entire contents of Program Files\Zune
This commit is contained in:
+41
-17
@@ -6,40 +6,64 @@ namespace ZuneHost
|
|||||||
{
|
{
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
static string? _zuneProgramFolder;
|
static string _zuneProgramFolder;
|
||||||
|
|
||||||
static void Main(string[] args)
|
[STAThread]
|
||||||
|
static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Creating splash window...");
|
Console.WriteLine("Creating splash window...");
|
||||||
|
|
||||||
string strArgs = string.Join(' ', args);
|
string strArgs = string.Join(" ", args);
|
||||||
|
|
||||||
// Make sure that ZuneDBApi can find all the Zune native libraries
|
// Make sure that ZuneDBApi can find all the Zune native libraries
|
||||||
Console.WriteLine("Setting up dependency resolver...");
|
Console.WriteLine("Copying Zune files...");
|
||||||
_zuneProgramFolder = Path.Combine(
|
_zuneProgramFolder = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
|
||||||
"Zune");
|
"Zune");
|
||||||
foreach (string file in Directory.GetFiles(_zuneProgramFolder))
|
foreach (var info in new DirectoryInfo(_zuneProgramFolder).GetFileSystemInfos())
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileName(file);
|
if (info is DirectoryInfo dirInfo)
|
||||||
if ((fileName.StartsWith("Zune") || fileName.StartsWith("UIX"))
|
|
||||||
&& file.EndsWith(".dll")
|
|
||||||
&& fileName != "ZuneDbApi.dll")
|
|
||||||
{
|
{
|
||||||
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
CopyAll(dirInfo, new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, dirInfo.Name)));
|
||||||
if (!File.Exists(targetPath))
|
}
|
||||||
File.Copy(file, targetPath);
|
else if (info is FileInfo fileInfo)
|
||||||
|
{
|
||||||
|
string fileName = fileInfo.Name;
|
||||||
|
if (fileInfo.Extension == ".dll")
|
||||||
|
{
|
||||||
|
string targetPath = Path.Combine(Environment.CurrentDirectory, fileName);
|
||||||
|
if (!File.Exists(targetPath) || fileName == "ZuneDbApi.dll")
|
||||||
|
fileInfo.CopyTo(targetPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Starting Zune...");
|
Console.WriteLine("Starting Zune...");
|
||||||
|
|
||||||
Thread zuneThread = new Thread(new ThreadStart(() =>
|
return Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
|
||||||
|
{
|
||||||
|
// Check if the target directory exists
|
||||||
|
if (Directory.Exists(target.FullName) == false)
|
||||||
{
|
{
|
||||||
Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, IntPtr.Zero);
|
Directory.CreateDirectory(target.FullName);
|
||||||
}));
|
}
|
||||||
zuneThread.SetApartmentState(ApartmentState.STA);
|
|
||||||
zuneThread.Start();
|
// Copy all the files into the new directory
|
||||||
|
foreach (FileInfo fi in source.GetFiles())
|
||||||
|
{
|
||||||
|
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Copy all the sub directories using recursion
|
||||||
|
foreach (DirectoryInfo diSourceDir in source.GetDirectories())
|
||||||
|
{
|
||||||
|
DirectoryInfo nextTargetDir = target.CreateSubdirectory(diSourceDir.Name);
|
||||||
|
CopyAll(diSourceDir, nextTargetDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user