Browse Category

Windows

BizSpark: una grande opportunità per noi!

Da oggi ikrotec è nella galassia Microsoft BizSpark.

 

 

BizSpark è un programma globale pensato da per accelerare il successo delle startup selezionate.  Microsoft fornirà gratuitamente ai partner: software, supporto, consulenza tecnica/business e visibilità marketing nazionale ed internazionale. Inoltre è garantito un accesso privilegiato alla piattaforma Windows Azure  e all’assistenza focalizzata sul tema del Cloud e dei device, Windows Phone 7.5 e Windows 8..

 

Registrare/Deregistrare una DLL o un OCX in Windows

Per registrare una DLL o un file OCX si utilizza il comando regsvr32 specificando il percorso del file. La deregistrazione/rimozione/unregsvr32 si ottiene semplicemente aggiungendo il parametro -u .

Esempio di registrazione:

regsvr32 C:\WINDOWS\system32\Nicola.ocx

Esempio di rimozione:

regsvr32 -u C:\WINDOWS\system32\Nicola.ocx

Gestione processi in Visual Basic

Esempio di ciclo per verificare l’esistenza di un processo e killarlo:

    Dim cnt As Integer 'tentativi.
    cnt = 10
    Do While IsProcessRunning("nomeprocesso.exe") = True
        
        If cnt = 0 Then
             Exit Do
        End If
        
        KillProcess ("nomeprocesso.exe")
        cnt = cnt - 1
        Sleep (2000)
    Loop

Verificare l’esistenza di un processo:

Option Explicit

Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long

Private Declare Function EnumProcesses Lib "PSAPI.DLL" ( _
lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long

Private Declare Function EnumProcessModules Lib "PSAPI.DLL" ( _
ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long

Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" ( _
ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long

Private Const PROCESS_VM_READ = &H10

Private Const PROCESS_QUERY_INFORMATION = &H400


Public Function IsProcessRunning(ByVal sProcess As String) As Boolean
    Const MAX_PATH As Long = 260
    Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long
    Dim sName As String
    sProcess = UCase$(sProcess)
    ReDim lProcesses(1023) As Long
    If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then
        For N = 0 To (lRet \ 4) - 1
            hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N))
            If hProcess Then
                ReDim lModules(1023)
                If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then
                    sName = String$(MAX_PATH, vbNullChar)
                    GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH
                    sName = Left$(sName, InStr(sName, vbNullChar) - 1)
                    If Len(sName) = Len(sProcess) Then
                        If sProcess = UCase$(sName) Then IsProcessRunning = True: Exit Function
                    End If
                End If
            End If
            CloseHandle hProcess
        Next N
    End If
End Function

Killare un processo:

Public Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szexeFile As String * 260
End Type

Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, _
ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

Declare Function ProcessFirst Lib "kernel32.dll" Alias "Process32First" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function ProcessNext Lib "kernel32.dll" Alias "Process32Next" (ByVal hSnapshot As Long, _
uProcess As PROCESSENTRY32) As Long

Declare Function CreateToolhelpSnapshot Lib "kernel32.dll" Alias "CreateToolhelp32Snapshot" ( _
ByVal lFlags As Long, lProcessID As Long) As Long

Declare Function TerminateProcess Lib "kernel32.dll" (ByVal ApphProcess As Long, _
ByVal uExitCode As Long) As Long

Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

Public Sub KillProcess(NameProcess As String)
    Const PROCESS_ALL_ACCESS = &H1F0FFF
    Const TH32CS_SNAPPROCESS As Long = 2&
    Dim uProcess  As PROCESSENTRY32
    Dim RProcessFound As Long
    Dim hSnapshot As Long
    Dim SzExename As String
    Dim ExitCode As Long
    Dim MyProcess As Long
    Dim AppKill As Boolean
    Dim AppCount As Integer
    Dim i As Integer
    Dim WinDirEnv As String

       If NameProcess <> "" Then
          AppCount = 0

          uProcess.dwSize = Len(uProcess)
          hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
          RProcessFound = ProcessFirst(hSnapshot, uProcess)

          Do
            i = InStr(1, uProcess.szexeFile, Chr(0))
            SzExename = LCase$(Left$(uProcess.szexeFile, i - 1))
            WinDirEnv = Environ("Windir") + "\"
            WinDirEnv = LCase$(WinDirEnv)

            If Right$(SzExename, Len(NameProcess)) = LCase$(NameProcess) Then
               AppCount = AppCount + 1
               MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
               AppKill = TerminateProcess(MyProcess, ExitCode)
               Call CloseHandle(MyProcess)
            End If
            RProcessFound = ProcessNext(hSnapshot, uProcess)
          Loop While RProcessFound
          Call CloseHandle(hSnapshot)
       End If

End Sub

Esportare dati in formato ODS (Foglio di Calcolo OpenDocument)

public static void ExportToOds(DataSet source, string fileName)
{
   System.IO.StreamWriter excelDoc;
   excelDoc = new System.IO.StreamWriter(fileName);
   excelDoc.Write("<table>");
   excelDoc.Write("<tr>");

   for (int x = 0; x < source.Tables[0].Columns.Count; x++)
   {
      excelDoc.Write("<td align=\"left\" valign=\"middle\" width=\"100%\"><strong>");
      excelDoc.Write(source.Tables[0].Columns[x].ColumnName);
      excelDoc.Write("</strong></td>");
   }

   excelDoc.Write("</tr>");

   foreach (DataRow x in source.Tables[0].Rows)
   {
      excelDoc.Write("<tr>");

      for (int y = 0; y < source.Tables[0].Columns.Count; y++)
      {
          excelDoc.Write("<td align=\"left\" valign=\"middle\">");
          excelDoc.Write(string.Format("{0}", x[y]));
          excelDoc.Write("</td>");
      }

      excelDoc.Write("</tr>");
   }

   excelDoc.Write("</table>");
   excelDoc.Close();
}

ICell – iPhoneTracker for Windows

ICell resume all your IPhone position history.

Version 0.2 – DOWNLOAD HERE >>>>>> [download id=”16″]<<<<<<<<<<

(Compiled Version, check if Framework 2.0 is present [download id=”14″] )

Changelog:

– Add Direct Map Viewer

– Add esport in light KML

– Add list mode viewer

——————————————————————————————————

Version 0.1 – DOWNLOAD HERE >>>>>> [download id=”12″]<<<<<<<<<<

How to use:

– Backup your IPhone by ITunes

– Download and run ICell

– Select your backup

– Save your file or Right Button and view in Google Maps


This application use Framework 2: Download here.

Based on http://petewarden.github.com/iPhoneTracker/

SDK per la firma digitale con algoritmo SHA-256

In seguito alla Determinazione Commissariale n. 69/2010 (del 28 luglio 2010) che modifica la Deliberazione CNIPA n. 45/2009 sono stati modificati i termini per l’utilizzo delle nuove regole a proposito di Firma Digitale.

Entro il 31 dicembre 2010 tutte le applicazioni che sfruttano questa tecnologia dovranno implementare i nuovi formati di firma (tra cui il più robusto algoritmo SHA-256) a partire dal 31 agosto 2010; devono rendere disponibili dette applicazioni entro il 31 dicembre 2010. Infatti oltre il 30 giugno 2011 i documenti firmati con il vecchio formato non saranno più validi. (Per approfondimenti: www.cnipa.gov.it)

Abbiamo quindi cercato una libreria che implementasse il famigerato SHA-256 e che permettesse varie tipologie di firma e di verifica.

ESEMPI DI UTILIZZO

Attivazione della liberia:

try
   {
        License.Activate(activationCode);
   }
catch (LicenseException ex)
   {
         return;
   }

Firma Semplice:

Pkcs7Result res = Pkcs7Utility.CreatePkcs7(string fileInput, string Pin, string fileOutput);
if (res != Pkcs7Result.Ok)
  {
      Error("Errore durante la firma: {0} - {1}", Pkcs7Utility.LastError, Pkcs7Utility.LastErrorMessage);
      return;
  }

Firma Parallela o Controfirma

Pkcs7Result res = Pkcs7Utility.AddSignature(fileInput, Pin, tmpFile);

Ottenere i certificati di firma:

X509Certificate2Collection listaCertificati;
bool  res = Pkcs7Utility.VerifyPkcs7(txtSelectedFile.Text, out listaCertificati, true);

Mostrare un certificato:

Pkcs7Utility.ShowCertificate(certificato);

Estrarre dati originali dal file firmato:

string fileOutput = Pkcs7Utility.GetOriginalFilename(fileInput);
bool res = Pkcs7Utility.ExtractDataFromPkcs7(fileInput, fileOutput);