Segna il video come già completato  
Se vuoi, sarebbe utile un giudizio su questo video    
In questo video vedremo come Visual Studio 2010 semplifica la gestione del nostro software installato su sistemi a 64bit che ormai stanno raggiungendo come popolarità i più classici sistemi a 32 bit. In questa nuova versione di Visual Studio la Microsoft ha infatti introdotto tre nuovi metodi di comodo Cioè tre nuove funzioni che possono essere chiamate direttamente ma che eseguono operazioni che era possibile effettuare anche prima della loro comparsa, a patto di usare strade sicuramente più complicate ed artigianali. Adesso vedremo il primo metodo, che ci permette di capire se il sistema operativo su cui il nostro codice gira è a 32 o a 64 bit. Anche con Visual Studio 2008 abbiamo la possibilità di eseguire questa verifica: if(IntPtr.Size == 8) { Console.WriteLine("Questa macchina è a 64 bit"); } else if(IntPtr.Size == 4) { Console.WriteLine("Questa macchina è a 32 bit"); } Cioè verifichiamo la dimensione in byte di un puntatore ad un intero sulla macchina su cui gira il nostro software. Se la macchina è a 64bit, la lunghezza è 8, se è a 32 bit la lunghezza è 4. Un altro metodo, molto poco consigliabile però, è quello di verificare se esiste la cartella C:\Programmi (x86), presente in tutti i sistemi a 64 bit. Questa verifica può essere effettuata nel seguente modo: if(Environment.GetEnvironmentVariable("ProgramFiles(x86)") != String.Empty){ Console.WriteLine("Questa macchina è a 64 bit"); } else { Console.WriteLine("Questa macchina è a 32 bit"); } Ancora, potremmo verificare se nel registro della propria macchina è presente il nodo HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. Per fare questo potremmo scrivere: if (Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node") != null) { Console.WriteLine("Questa macchina è a 64 bit"); } else { Console.WriteLine("Questa macchina è a 32 bit"); } Console.Read(); ricordiamoci però che gli ultimi due sistemi sono molto rischiosi. Esistono infatti alcuni software che, invece di verificare l'architettura del sistema operativo in cui andranno ad installarsi, si installano in Programi (x86) e registrano le proprie chiavi in Wow6432Node. Se sono in presenza di un sistema operativo a 64 bit, allora la directory e il nodo di registro saranno già esistenti. In caso contrario verranno create. Questo comportamento anomalo rende naturalmente molto pericoloso effettuare verifiche usando questi criteri. Fortunatamente in VS2010 possiamo utilizzare un metodo apposito per conoscere l'architettura del nostro sistema: Console.WriteLine(Environment.Is64BitOperatingSystem); Console.ReadKey(); che è di tipo booleano e quindi restituirà true se il sistema è a 64 bit e false se è a 32. In questo video vedremo come Visual Studio 2010 semplifica la gestione del nostro software che andremo installare sui sistemi a 64 bit. Sistemi che ormai stanno raggiungendo come popolarità i più classici sistemi a 32 bit. In questa nuova versione di Visual Studio 2010 infatti la Microsoft ha introdotto tre nuovi metodi di comodo cioè tre nuove funzioni che possono essere chiamate direttamente ma che è un'operazione che era possibile effettuare anche prima della loro comparsa a patto però di usare le strade sicuramente più complicate e diciamo anche artigianali. In questo video vedremo il primo metodo che ci permetterà di capire se il sistema operativo su cui girerà nostro codice e a 32 o a 64 bit. Come abbiamo detto poco fa anche con Visual Studio 2008 troviamo la possibilità di effettuare questa verifica. In particolare con un codice simile a questo cioè praticamente verificando la dimensione in byte di un puntatore ad un intero sulla macchina su cui gira nostro software. Se la macchina è a 64 bit allora la lunghezza del puntatore sarà 8, se invece nostra macchina 32 bit, la lunghezza del puntatore sarà 4. Per cui se andiamo ad eseguire questo codice, possiamo verificare che effettivamente il codice gira su una macchina 32 bit. Altro metodo alternativo però poco consigliabile consiste nel verificare l'esistenza della cartella c:\programmi (x86) che è presente in tutti sistemi a 64 bit. Questa cartella è la cartella dove andranno installati tutti software a 32 bit su un sistema a 64 bit. La verifica della presenza di questa cartella può essere effettuata utilizzando questo codice cioè utilizzando un metodo Environment.GetEnvironmentVariable varie volte utilizzando come parametro la variabile d'ambiente program files (x86). Se questa è diversa da null allora la macchina è a 64 bit altrimenti è a 32. Lanciamo nuovamente questo codice effettivamente viene rilevato una macchina a 32 bit e ancora possiamo verificare se nella propria macchina presente il nodo HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node, ossia questo nodo qui. Per poter verificare la presenza di questo nodo possiamo usare il seguente codice cioè tentiamo di aprire la chiave HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. Se questa chiave non è nulla allora la macchina sarà 64 bit in caso contrario sarà a 32. Avviando il codice possiamo verificare che anche questa volta la macchina è stata rilevata 32 bit. Ricordiamoci però che gli ultimi due sistemi che abbiamo visto cioè la verifica della presenza della cartella ci programmi (x86) e la presenza della chiaveHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node è molto rischioso infatti esistono alcuni software che, invece di verificare l'architettura del sistema operativo in cui andranno ad installarsi si installano direttamente in programmi (x86), registrano le proprie chiavi in Wow6432Node quindi se siamo in presenza di un sistema operativo 64 bit allora sia la cartella che il nodo di registro sarà già, esistente per cui non faranno altro che nella scrivere dentro questi elementi già esistenti in caso contrario a queste chiavi e questa cartella verranno create automaticamente e questo comportamento anomalo rende naturalmente molto pericoloso effettuare verifiche utilizzando questi criteri fortunatamente Visual studio 2010 c'è una possibilità di utilizzare un metodo apposito per conoscere l'architettura del nostro sistema questo metodo e Is64bitOperatingSystem se proviamo ad avviare questo codice vediamo che ci viene restituito false quindi non è un sistema 64 bit e quindi è un sistema a 32.
In this video we will see how Visual Studio 2010 simplifies the management of our software we will install on 64 bit systems. Systems that are now reaching the popularity as more traditional 32-bit systems. In this new version of Visual Studio 2010 because Microsoft has introduced three new methods of convenience that is, three new functions that can be called directly, but that is a task that was possible even before their appearance as long as we use the streets safe more complicated and we also craft. In this video we will see the first method that will allow us to understand if the operating system will be running our code and 32 or 64 bits. As we said earlier with Visual Studio 2008 there is the possibility to verify this. In particular, code like this that is pretty sure the size in bytes of a pointer to an integer on the machine running our software. If the machine is 64 bits then the length of the pointer will be 8, but if our 32-bit machine, the length of the pointer is 4. So if we're going to run this code, we can actually verify that the code runs on a 32 bit machine. Another alternative method is however not advisable to verify the existence of the folder c: \ program files (x86) that is present in all 64-bit systems. This folder is the folder where all software will be installed on a 32-bit 64-bit system. The verification of the presence of this folder can be done using this code that is using a method Environment.GetEnvironmentVariable several times using the environment variable as a parameter program files (x86). If this is non-null then the machine is 64-bit otherwise it is 32. We launch again this code is actually detected a 32-bit machine and we can still check if your machine has the node HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node, ie this node here. In order to verify the presence of this node we can use the following code that tries to open the key HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node. If this key is not nothing then the machine will be 64-bit otherwise it will be a 32. In launching the code we can see that this time the car was found 32 bits. But let us remember that the last two systems we have seen that is the verification of the presence there of the folder program files (x86) and the presence of chiaveHKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node is very risky since there are some software that, instead of verifying the OS architecture in which are going to install are installed directly in program files (x86), record your keys in Wow6432Node so if we are in the presence of a 64-bit operating system and then the folder node register is already in existence that will only in type in these elements already exist, otherwise these keys and this folder will be created automatically, and this abnormal behavior makes it very dangerous course carry out using these criteria fortunately Visual Studio 2010 there is a chance to use a special method to know the architecture of our system and this method Is64bitOperatingSystem if we try to run this code we see that there is not false is returned then a 64 bit system is a system and then to 32.