Home page Documenti>

Archivio di materiali

Note: "È stato superato il numero massimo di cursori aperti ORA-01000" [Java]

Note sul errore di OracleDB che: "È stato superato il numero massimo di cursore aperto ORA-01000" sono imbattuto l'altro giorno.

È diventato un problema simile al seguente codice
(. Non confermate il funzionamento. Thing per esporre il codice per il lavoro di traduzione non andrà, riscritto come un campione)

import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; public class cursorLeakeSample { public cursorLeakeSample(List idList) { try { // Oracle JDBC Driverのロード Class.forName("oracle.jdbc.driver.OracleDriver"); // コネクション取得 Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger"); String sql = "SELECT NAME FROM ITEM WHERE ID = ?"; PreparedStatement statement = null; try { for (String id : idList) { Object[] params = new Object[] { id }; // SQLにパラメータ埋め込みと実行statement = connection.prepareStatement(sql); statement.setObject(1, params[0]); statement.executeUpdate(); connection.commit(); } } catch (SQLException e) { // SQL実行失敗 connection.rollback(); e.printStackTrace(); } finally { statement.close(); connection.close(); } } catch (SQLException e) { // コネクションの接続・切断・ロールバック、ステートメントの解放に失敗 e.printStackTrace(); } catch (ClassNotFoundException e) { // Oracle JDBC ドライバが見つからなかった e.printStackTrace(); } } }  import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; public class cursorLeakeSample { public cursorLeakeSample(List idList) { try { // Oracle JDBC Driverのロード Class.forName("oracle.jdbc.driver.OracleDriver"); // コネクション取得 Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger"); String sql = "SELECT NAME FROM ITEM WHERE ID = ?"; PreparedStatement statement = null; try { for (String id : idList) { Object[] params = new Object[] { id }; // SQLにパラメータ埋め込みと実行statement = connection.prepareStatement(sql); statement.setObject(1, params[0]); statement.executeUpdate(); connection.commit(); } } catch (SQLException e) { // SQL実行失敗 connection.rollback(); e.printStackTrace(); } finally { statement.close(); connection.close(); } } catch (SQLException e) { // コネクションの接続・切断・ロールバック、ステートメントの解放に失敗 e.printStackTrace(); } catch (ClassNotFoundException e) { // Oracle JDBC ドライバが見つからなかった e.printStackTrace(); } } } 

E 'la parte in cui l'enfasi che ha causato.
Sapete perché no?
Innanzitutto, attivare mettere un valore da utilizzare come una scatola vuota per creare una dichiarazione variabile, ottenuto in un ciclo, rilasciato alla fine.
A prima vista, sembra così causando la perdita è una versione, è possibile trovare il problema e seguire il processo un po '.

"PrepareStatement" creerà un cursore implicito per la preparazione di SQL.
Il codice in questione è molto implicito che il cursore è stato generato nel ciclo e sapere che questo.
Ed è stato rilasciato solo uno dei "prepareStatement" L'ultimo che è stato memorizzato in uscita dal ciclo.

Ad esempio, 19 non è che non essere rilasciato se il processo era di 20.

Allora, che cosa dovrei scrivere, se

 import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; public class cursorLeakeSample { public cursorLeakeSample(List idList) { try { // Oracle JDBC Driverのロード Class.forName("oracle.jdbc.driver.OracleDriver"); // コネクション取得 Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger"); String sql = "SELECT NAME FROM ITEM WHERE ID = ?"; PreparedStatement statement = connection.prepareStatement(sql); try { for (String id : idList) { Object[] params = new Object[] { id }; // SQLにパラメータ埋め込みと実行 statement.setObject(1, params[0]); statement.executeUpdate(); connection.commit(); } } catch (SQLException e) { // SQL実行失敗 connection.rollback(); e.printStackTrace(); } finally { statement.close(); connection.close(); } } catch (SQLException e) { // コネクションの接続・切断・ロールバック、ステートメントの解放に失敗 e.printStackTrace(); } catch (ClassNotFoundException e) { // Oracle JDBC ドライバが見つからなかった e.printStackTrace(); } } }  import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; public class cursorLeakeSample { public cursorLeakeSample(List idList) { try { // Oracle JDBC Driverのロード Class.forName("oracle.jdbc.driver.OracleDriver"); // コネクション取得 Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:ORCL", "scott", "tiger"); String sql = "SELECT NAME FROM ITEM WHERE ID = ?"; PreparedStatement statement = connection.prepareStatement(sql); try { for (String id : idList) { Object[] params = new Object[] { id }; // SQLにパラメータ埋め込みと実行 statement.setObject(1, params[0]); statement.executeUpdate(); connection.commit(); } } catch (SQLException e) { // SQL実行失敗 connection.rollback(); e.printStackTrace(); } finally { statement.close(); connection.close(); } } catch (SQLException e) { // コネクションの接続・切断・ロールバック、ステートメントの解放に失敗 e.printStackTrace(); } catch (ClassNotFoundException e) { // Oracle JDBC ドライバが見つからなかった e.printStackTrace(); } } } 

Forse in questo modo. Se si utilizza il "PreparedStatement".
Cosa penso, close () nella dichiarazione quindi se volete usarlo per Tadano "Dichiarazione".

Aggiunta dinamica di [Java] path Class

Nota: Ora che abbiamo implementato a modo mio ci penso e si desidera creare un programma con riferimento alla ammorbidimento della Jar Tomcat WEB-INF/classes e altri sistemi.
" One-Jar "o" Fat Jar Se pensate che può rispondere con "e non vi sarebbe meglio sfruttare.
Per inciso, il controllo del funzionamento è stato confermato che funziona anche quando riassunte in the Jar è JRE5.

 package jp.moonwing.net; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; /** * クラスパスの動的追加 * * @author $Author: U.Yobane $ * @version $Version: v 043b2b764886 2011/06/13 01:23:25+0900(JST) $ */ public final class ApplicationClassLoader { /** クラス情報格納フィールド */ private static final Class<?>[] PARAMETERS = new Class<?>[] { URL.class }; /** * コンストラクタ */ private ApplicationClassLoader() { } /** * メイン * * @param args 起動引数文字列配列 */ public static void main(String[] args) { try { // クラスパスの追加 addClassPath( {追加したいクラスパスディレクトリ} ); addClassPath( {追加したいJAR} ); // メインプログラムを実行 Application.execute(args); } catch (IOException e) { e.printStackTrace(); } } /** * クラスローダーにクラスパスを動的追加 * * @param classPath 追加するクラスパス * @throws IOException クラスパスの動的追加に失敗 */ public static void addClassPath(String classPath) throws IOException { addClassPath(new File(classPath)); } /** * クラスパスを再帰的にたどり、追加可能パスはすべて追加 * * @param classPath 追加するファイル * @throws IOException クラスパスの動的追加に失敗 */ private static void addClassPath(File classPath) throws IOException { if (classPath.isDirectory()) { // ディレクトリを追加 addClassPath(classPath.toURL()); // ディレクトリ配下を探索 File[] child = classPath.listFiles(); for (int i = 0; i < child.length; i++) { addClassPath(child[i]); } } else { String suffix = getSuffix(classPath.getName()); // 見つかったファイルがJARもしくはZipの場合は追加 if (suffix.equalsIgnoreCase("zip") || suffix.equalsIgnoreCase("jar")) { addClassPath(classPath.toURL()); } } } /** * システムクラスローダーにクラスパスを強制的に追加 * * @param classPathUrl クラスパス * @throws IOException クラスパスの動的追加に失敗 */ private static void addClassPath(URL classPathUrl) throws IOException { URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader(); Class<?> sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("addURL", PARAMETERS); method.setAccessible(true); method.invoke(sysloader, new Object[] { classPathUrl }); } catch (NoSuchMethodException e) { throw new IOException("could not add " + classPathUrl + " to classpath"); } catch (InvocationTargetException e) { throw new IOException("could not add " + classPathUrl + " to classpath"); } catch (IllegalAccessException e) { throw new IOException("could not add " + classPathUrl + " to classpath"); } } /** * ファイル名から拡張子を返却 * * @param fileName ファイル名 * @return ファイルの拡張子 */ private static String getSuffix(String fileName) { if (fileName == null) { return null; } int point = fileName.lastIndexOf("."); if (point != -1) { return fileName.substring(point + 1); } return fileName; } } 

UAC sostegno del [C #] Applicazione

Nota: Se si desidera modificare il comportamento in generale ei diritti ei privilegi amministrativi sul lato applicazione

  1. A giudicare dalle informazioni se la versione di OS è stata avviata dal WindowsVista è <br /> o l'applicazione è in esecuzione in uno (OS con UAC) e poi WindowsVista

     using System; private bool IsUAC() { OperatingSystem osInfo = Environment.OSVersion; if (osInfo.Platform == PlatformID.Win32NT) { if (osInfo.Version.Major == 6) { if (osInfo.Version.Minor == 0) { // Windows Vista, Windows Server 2008 return true; } else if (osInfo.Version.Minor == 1) { // Windows 7, Windows Server 2008 R2 return true; } } else if (osInfo.Version.Major > 6) { // new Windows return true; } } return false; } 
  2. Quando sono ... "Esegui come amministratore" è <br /> o applicazione è stata avviata l'applicazione con privilegi di amministratore

     using System.Security.Principal; private bool IsAdministrator() { bool isAllowed = false; try { WindowsIdentity wi = WindowsIdentity.GetCurrent(); WindowsPrincipal wp = new WindowsPrincipal(wi); isAllowed = wp.IsInRole(WindowsBuiltInRole.Administrator); } catch { isAllowed = false; } return isAllowed; } 
  3. L'utente che ha avviato l'applicazione <br /> Se vuoi sapere se l'applicazione può essere promosso per l'utente amministratore che ha avviato anche se è stato avviato con i privilegi che appartengono al gruppo Administrators o generale

     using System.DirectoryServices.AccountManagement; private bool IsAdministrators() { bool isAllowed = false; try { PrincipalContext pc = new PrincipalContext(ContextType.Machine, null); UserPrincipal up = UserPrincipal.Current; GroupPrincipal gp = GroupPrincipal.FindByIdentity(pc, "Administrators"); if (up.IsMemberOf(gp)) { isAllowed = true; } } catch { isAllowed = false; } return isAllowed; } 

    Piace non funziona bene in alcuni ambienti e che il codice di cui sopra? Può garantire che la maggior parte il codice qui sotto.

     using System.DirectoryServices.AccountManagement; private bool IsAdministrators() { bool isAllowed = false; try { PrincipalContext pc = new PrincipalContext(ContextType.Machine, null); UserPrincipal up = UserPrincipal.Current; foreach (GroupPrincipal gp in up.GetGroups()) { try { if (gp.Name.ToLower().Equals("Administrators".ToLower())) { isAllowed = true; } } finally { gp.Dispose(); } } } catch { isAllowed = false; } return isAllowed; } 
  4. Con privilegi di amministratore a riavviarsi da solo se l'autorità amministrativa che è stato richiesto quando il trattamento <br /> riavviare l'applicazione con privilegi di amministratore

     using System; using System.Diagnostics; private void RestartApplication() { ProcessStartInfo psi = new ProcessStartInfo(); psi.UseShellExecute = true; psi.WorkingDirectory = Environment.CurrentDirectory; psi.FileName = Application.ExecutablePath; psi.Verb = "runas"; try { Process p = Process.Start(psi); } catch { return; } Application.Exit(); } 
  5. Per visualizzare l'icona della (verticale) UAC sul pulsante per informare l'utente che richiede privilegi amministrativi per continuare l'operazione per visualizzare un'icona <br /> (verticale) UAC al pulsante che deve avere privilegi di amministratore (L'icona scudo e Win32API icona scudo proprietà SystemIcons.Shield c'è una differenza, è stato utilizzato come standard in Windows 7. che è più Win32 API)

     using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace Sample { public partial class Form1 : Form { [DllImport("user32.dll")] private static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam); // 第2パラメータ:盾アイコンを設定するフラグ uint BCM_SETSHIELD = 0x0000160C; public Form1() { InitializeComponent(); // ボタンの外観を「System」にする必要がある button1.FlatStyle = FlatStyle.System; } private void checkBox1_CheckedChanged(object sender, EventArgs e) { // 第1パラメータ:ボタンのウィンドウ・ハンドル HandleRef hwnd = new HandleRef(button1, button1.Handle); if (checkBox1.Checked) { SendMessage(hwnd, BCM_SETSHIELD, new IntPtr(0), new IntPtr(1)); } else { SendMessage(hwnd, BCM_SETSHIELD, new IntPtr(0), new IntPtr(0)); } } } } 

PSP retroilluminazione fusibile di ricambio

PSPのバックライトヒューズの位置
PSP-1000 schermo non appare all'improvviso.
Sento il suono, il suono che si sente anche un pulsante.

E sguardo duro, sottile monitor di appena ー grafica era stato.

Vieni veramente pionieri ed esaminare le informazioni sulla rete e poi di indovinare la retroilluminazione è scaduto da questa situazione.

Immediatamente, la decomposizione, e quindi provare a verificare la continuità del fusibile che toccava a me di pubblicare la posizione del fusibile della retroilluminazione con attenzione.

Con un multimetro digitale, ma nessuna reazione, lo stesso fusibile non sapeva di cosa si tratta propriamente ortogonalità delle sue dimensioni fusibili 1005 chip.
Per esempio, non sarebbe essere misurato o se vi pellicola sottile sulla superficie.

Ho deciso di sostituire su spec.
Sostituzione del fusibile 0,5 A per la F4501.
In primo luogo, come credo rinunciare non fondere le saldature, ma pensavo che si sta sostituendo una politica.
Pertanto, abbiamo deciso di mettere in parallelo.
(Se il fusibile esistente era vivo, perché la corrente è diviso) se questo, a rigor di termini, ma non anche un bene,
E 'considerato recuperato se la retroilluminazione in questo lavoro, il fusibile non è la stessa off,
Separatamente, come se non c'è una causa buona, così eliminando buona.

Si, il lavoro di recupero è stato effettuato in modo sicuro retroilluminazione.
PSP è stato quello di giocare nuovamente.

Riparazione Kurobox di potere

玄箱の電源回路のヒューズ リード付きヒューズ
Collegare l'alimentatore rimane sorella Kurobox, accidentalmente toccato il potere, si noti che, poiché i lavori di riparazione dovuto spegnere il fusibile

Gen è la prima cosa della scatola unbranded.
Ma in realtà che stava per staccare la spina di alimentazione sia tirato fuori un altro cavo di alimentazione, il potere Kurobox non mancava.
Scintilla blu era morto avrebbe toccato il piede con un fusibile del potere di resistenza dovuta al lavoro come mancanti.

Potenza non entra come previsto anche il potere di applicare alla mano per andare a dormire è in fretta senza occhi che danno, per assicurarsi che non hanno fallito.
Sì, se la potenza era di andare coda Kurobox. Se questo accade troppo tardi.

Ho dovuto recuperare e sostituire il fusibile, non deve aver avuto la gente guarda come è breve in rete, mentre cerca di ammaccature informazione.

Ma per ora, anche se proprio un fusibile bruciato? Per verificare la continuità della (F1) fusibile con un multimetro digitale e pensare.
Risultato non è stato condotto. Ciò significa che il fusibile è scaduta.
Questo può essere fortunati.
Fusibile dal circuito destinato a tagliare in modo da non danneggiare il circuito quando essa diventa eccessiva tensione o corrente eccessiva, il circuito di protezione temperatura anormale, c'è una possibilità Nei altra parte non è danneggiato a causa potrebbe essere così fortunati.
E che è possibile vedere la continuità del fusibile al contrario, sarà parte dell'altro è danneggiato, è difficile identificare la causa.

Ebbene, il centro radio era Onuma stava cercando un fusibile da 3A in Akihabara con piombo sulla base delle informazioni in rete.
Era di 150 yen in due. Il problema è stato scoperto con il viaggio di ritorno, mentre E penso Akihabara, infatti, fare il lavoro e subito lo scambio

Perché è scritto con fusibile 2A Se si guarda da vicino l'originale.
Ma passando da 3A si fondono ma l'unica cosa che collega il circuito, anche quando era sovracorrente 2A 3A diventa normale.
Questo perché il danno potenziale in altre parti del fusibile quando sovracorrente è nato per scambiare nuove persone piace comprare 2A.

Va notato, era in grado di retrofit senza problemi con il piombo piombo del fusibile è stato acquistato, ma era un po 'di spessore.
E, assicurarsi che sia possibile si avvia correttamente Quando si accende.

Se si trova un fusibile cercando di sostituire 2A piombo · · ·

Creare e firmare per il certificato dell'editore [VS] software

Nota della firma metodo di come creare e firmare un certificato per creare le cose.

Se si desidera utilizzare ClickOnce per installare il VSTO o certificato autofirmato, il certificato deve essere Oreore e lo ha fatto, che cosa avete bisogno.
Lo strumento da utilizzare WindowsSDK che è incluso nel.

  • Come creare
     rem 1.==== rem CA:Certificate Authority:認証局証明書rem 会社名 : MoonWing rem 組織名 : MoonWing Authority Root CA rem 県 名 : Tokyo rem 国 名 : JP rem 有効期限: 2012.12.31 "%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\makecert" -r -n "C=JP, S=Tokyo, OU=MoonWing Authority Root CA, O=MoonWing" -e 12/31/2012 -a sha1 -cy authority -sv moonwingCA.pvk moonwingCA.cer rem 秘密キーのパスワードの作成:Subject Key: rootCA rem 秘密キーのパスワードの入力:Subject Key: rootCA rem 2.==== rem EE:End Entity:署名用証明書rem コモン名: MoonWing rem 会社名 : MoonWing rem 組織名 : MoonWing Development rem 県 名 : Tokyo rem 国 名 : JP rem 有効期限: 2012.12.31 "%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\makecert" -n "CN=MoonWing, C=JP, S=Tokyo, O=MoonWing, OU=MoonWing Development" -e 12/31/2012 -sv moonwing.pvk -ic moonwingCA.cer -iv moonwingCA.pvk -nscp -cy end moonwing.cer rem 秘密キーのパスワードの作成:Subject Key: endEntity rem 秘密キーのパスワードの入力:Subject Key: endEntity rem 秘密キーのパスワードの入力:Issuer Signature: rootCA rem 3.==== rem SPC:Software Publisher's Certificate:ソフトウェア発行元証明書"%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\Cert2SPC" moonwing.cer moonwingCA.cer moonwing.spc rem 4.==== rem PFX:Personal Information Exchange:PKCS#12 rem -pi(pvkpassword):endEntity rem -po(pfxpassword):SPC "%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\pvk2pfx" -pvk moonwing.pvk -pi endEntity -spc moonwing.spc -pfx moonwing.pfx -po SPC 
  • Firma del metodo
     rem 5.==== rem target.exeへ署名rem -t(time stamp server):http://timestamp.verisign.com/scripts/timstamp.dll rem -p(pfxpassword):SPC "%ProgramFiles%\Microsoft SDKs\Windows\v7.1\Bin\signtool" sign /f moonwing.pfx /a /t http://timestamp.verisign.com/scripts/timstamp.dll /p SPC target.exe 

Riassunto compliant version [VS] PIA

Versione della tabella. Versione NETFramework del PIA con la versione di Office e VSTO tabella creata nel passaggio.
PIA è ... e che PrimaryInteropAssembly più Microsoft prega di chiedere.

PIA Ufficio di supporto . NETFramework supporto Supporto di Windows
XP XP 1,1 XP
2003 2003 1,1 2000 SP3, XP, Server 2003
2007 2007 1,1 2000 SP4, XP SP2, Server 2003
2010 2010 2.0 o superiore 2000 SP4, XP SP2, Server 2003, Vista, 7, Server 2008

Compatibile con la versione Riassunto [VS] VSTO

È stato creato a causa di mancanza di una versione della tabella. NETFramework versione e la versione di Office e VSTO.
VSTO è e

  • Microsoft Visual Studio 2005 Tools per Office Second Edition Runtime
  • Microsoft Visual Studio 2005 Tools per Microsoft Office System 2007
  • Microsoft Visual Studio Tools per Microsoft Office System (versione 3.0 Runtime)
  • Microsoft Visual Studio 2010 Tools per Microsoft Office System (versione 4.0 Runtime)

Ufficio per l'estensione del componente è che il nome è cambiato sottilmente con.
In sostanza non dovrebbe essere un problema se le seguenti tre due occhi di cui sopra è stato omesso.
(. O che, posso anche omesso i primi tre, ma non sarà in grado di corrispondere alla fine in due 2003,2007,2010)

VSTO Ufficio di supporto . NETFramework supporto Supporto VisualStduio Supporto di Windows
2005 SE 2003, 2007 2,0 2005 2000, XP, Server 2003, Vista, 7, Server 2008
3,0 2007 3.5 SP1 2008 2000, XP, Server 2003, Vista, 7, Server 2008
4.0 2007,2010 3.5 SP1 2010 XP, Server 2003, Vista, 7, Server 2008

Direttive

Nota per isolare la parte delle direttive del preprocessore dipendenti dalla piattaforma durante la scrittura di codice cross-platform.

  • Compiler
    • GCC
      • # Ifdef __ GNUC__
        • O più # if __ GNUC__> = 3 / / GCC3.0
    • Borland C + +
      • # Ifdef __ BORLANDC__
    • Intel Compiler
      • # Ifdef __ INTEL_COMPILER
    • Microsoft Compiler
      • # Ifdef _MSC_VER
        • # VC in seguito, se _MSC_VER> = 600 / / C Compiler 6.0 + + compreso
        • # VC in seguito, se _MSC_VER> = 700 / / C / C + + Compiler 7.0 + + compreso
        • # Se poi _MSC_VER> = 800 / / VC + 1,0
        • # Se poi _MSC_VER> = 900 / / VC + 2,0
        • # Se poi _MSC_VER> = 1000 / / VC + 4,0
        • # Se poi _MSC_VER> = 1010 / / VC + 4,1
        • # Se poi _MSC_VER> = 1020 / / VC + 4,2
        • # Se poi _MSC_VER> = 1100 / / VC + 5,0
        • # Se poi _MSC_VER> = 1200 / / VC + 6,0
        • # Se _MSC_VER> = 1300 / / VC2002 più tardi (VC7.0)
        • # Se _MSC_VER> = 1310 / / VC2003 più tardi (VC7.1)
        • # Se _MSC_VER> = 1400 / / VC2005 più tardi (VC8.0)
        • # Se _MSC_VER> = 1500 / / VC2008 più tardi (VC9.0)
        • # Se _MSC_VER> = 1600 / / VC2010 più tardi (VC10.0)
  • Sistema UNIX
    • UNIX
      • # Ifdef __ unix
      • # Ifdef __ unix__
    • Linux
      • # Ifdef __ linux
      • # Ifdef __ linux__
    • FreeBSD
      • # Ifdef __ FreeBSD__
    • NetBSD
      • # Ifdef __ NetBSD__
    • Cygwin
      • # Ifdef __ CYGWIN__
      • # Ifdef __ versione Cygwin CYGWIN32__ / / 32bit
    • MinGW (-mno-cygwin)
      • # Ifdef __ MINGW32__
  • Di sistema di Windows
    • CUI
      • # Ifdef _CONSOLE
    • GUI
      • # Ifdef _WINDOWS
    • Windows a 32 bit
      • # Ifdef WIN32
      • # Ifdef _WIN32
    • Windows a 64 bit
      • # Ifdef _WIN64
    • Versione di Windows
      • # Ifdef WINVER
        • Dal # if (WINVER> = 0x030a) / / Windows 3.1
        • # Dal 95 / NT4.0 (WINVER> = 0 × 0400) / / Windows se
        • Dal # if (WINVER> = 0 × 0410) / / Windows 98
        • Dal # if (WINVER> = 0 × 0500) / / Windows Me / 2000
        • Dal # if (WINVER> = 0 × 0501) / / Windows XP / Server 2003
        • # Dal 2003 SP1 (WINVER> = 0 × 0502) / / Windows XP SP2 / Server, se
        • Dal # if (WINVER> = 0 × 0600) / / Windows Vista / Server 2008
        • Dal # if (WINVER> = 0 × 0601) / / Windows 7
      • # Ifdef _WIN32_WINDOWS / / Windows9x
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0400) / / Windows 95
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0410) / / Windows 98
        • # Se più tardi (_WIN32_WINDOWS> = 0 × 0500) / / Windows Me
      • # Ifdef _WIN32_WINNT / / WindowsNTx
        • / / Dal momento che Windows 2000 (0 × 0500)
          # Se (_WIN32_WINNT> _WIN32_WINNT_WIN2K =)
        • / / Dal 2003 Windows XP / Server (0 × 0501)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WINXP)
        • / / Dal 2003 SP1 di Windows XP SP2 / Server (0 × 0502)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WS03)
        • / / Da Windows Vista (0 × 0600)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_VISTA)
        • / / Da Windows Server 2008 (0 × 0600)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WS08)
        • / / Da Windows 7 (0 × 0601)
          # Se (_WIN32_WINNT> = _WIN32_WINNT_WIN7)
      • # Ifdef _WIN32_WCE / / WindowsCE
        • # Se (_WIN32_WCE> = 0 × 0420) / / Windows Mobile 2003 (PPC2003)
        • # Se (_WIN32_WCE> = 0 × 0421) / / Windows Mobile 2003 SE (PPC2003SE)
        • # Se (_WIN32_WCE> = 0 × 0501) / / Windows Mobile 5.0
        • # Se (_WIN32_WCE> = 0 × 0502) / / Windows Mobile 6 Professional / Classic
        • # Se (WINCEOSVER> = 0 × 0300) / / WindowsCE3.0 più tardi (PPC2002)
        • # Se (WINCEOSVER> = 0 × 0420) / / WindowsCE4.2 più tardi (PPC2003)
        • # Se (WINCEOSVER> = 0 × 0500) / / WindowsCE5.0 più tardi (WM5.0)
    • Internet Explorer versione
      • # Ifdef _WIN32_IE
        • # Se (_WIN32_IE> = 0 × 0200) / / Windows 95/NT 4.0 (Comctl32.dll 4,00, Shell32.dll 4.00)
        • # Se (_WIN32_IE> = 0 × 0300) / / Internet Explorer 3.0, 3.01, 3.02
        • # Se (_WIN32_IE> = 0 × 0400) / / Internet Explorer 4.0
        • # Se (_WIN32_IE> = 0 × 0401) / / Internet Explorer 4.01
        • # Se (_WIN32_IE> = 0 × 0500) / / Internet Explorer 5.0, 5.0a, 5.0b
        • # Se (_WIN32_IE> = 0 × 0501) / / Internet Explorer 5.01
        • # Se (_WIN32_IE> = 0 × 0550) / / Internet Explorer 5.5
        • # Se (_WIN32_IE> = 0 × 0600) / / Internet Explorer 6.0
        • # If (_WIN32_IE> = 0 × 0601) / / Internet Explorer 6.0 SP1
        • # Se (_WIN32_IE> = 0 × 0603) / / Internet Explorer 6.0 SP2
        • # Se (_WIN32_IE> = 0 × 0700) / / Internet Explorer 7.0
        • # Se (_WIN32_IE> = 0 × 0800) / / Internet Explorer 8.0

Nota <br /> preprocessore, a considerare come identificatore undefined 0, # if __ GNUC__> = 3 o più, ma può essere utilizzato come gcc3,
Se si tenta di stabilire # if __ GNUC__ <3 se il sistema GCC2, comprendono quelli che non sono GCC.
Riferimento

Ottiene la versione di Windows

Ma io non credo di poter utilizzare, provvisoriamente nota.
Se il compilatore può essere compilato senza problemi e penso di sistema di Windows.
Timidamente, compilare e confermare l'operazione è stata effettuata in MinGW.

 #include <windows.h> #include <stdio.h> int main(void) { unsigned int GV = GetVersion(); printf("GetVersion API(GV) = %08X\n\n", GV); printf("_winver = %08X\n", _winver); printf("_winmajor = %08X\n", _winmajor); printf("_winminor = %08X\n", _winminor); printf("_osver = %08X\n\n", _osver); printf("(( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF = %08X (= _winver)\n", (( GV << 8 ) | (( GV >> 8 ) & 0XFF)) & 0XFFFF ); printf("GV & 0XFF = %08X (= _winmajor)\n", GV & 0XFF ); printf("( GV >> 8 ) & 0XFF = %08X (= _winminor)\n", (( GV >> 8 ) & 0XFF)); printf("GV >> 16 = %08X (= _osver)\n\n\n", (GV >> 16) ); // Windows version(_winmajor, _winminor, _osver) printf("This system is ["); if ( _osver < 0X8000 ) { // NT Group (_osver LowWORD MSB = 0) switch (_winmajor) { case 3: case 4: printf ("Windows NT %u.%u Build %u", _winmajor, _winminor, _osver); break; case 5: switch (_winminor) { case 0: printf ("Windows 2000 Build %u", _osver); break; case 1: printf ("Windows XP Build %u", _osver); break; case 2: printf ("Windows Server 2003 family Build %u", _osver); break; default: printf ("NT Group Windows Build %u", _osver); } break; case 6: switch (_winminor) { case 0: printf ("Windows Vista or Windows Server 2008 Build %u", _osver); break; case 1: printf ("Windows 7 Build %u", _osver); break; default: printf ("NT Group Windows Build %u", _osver); } break; default: printf ("NTGroup Windows Build %u", _osver); } } else { switch (_winmajor ) { case 0: //Win32s Group case 1: case 2: case 3: printf ("Win32s Build %u", _osver & 0X7FFF); break; case 4: // 9X Group (_osver is invalid.) switch (_winminor) { case 0: printf ("Windows 95 Build ----"); break; case 10: printf ("Windows 98 Build ----"); break; case 90: printf ("Windows Me Build ----"); break; default: // To make sure printf ("Newer than Windows Me"); } break; default: // To make sure printf ("Newer than Windows Me"); } } printf("]"); return 0; } 
1 2 3

Home page Documenti>

Cerca
Alimentare
Traduzione
Japanese flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagEnglish flagGerman flagFrench flagRussian flagVietnamese flagThai flag

Torna all'inizio della pagina