[Ttssh2-commit] [9201] VS2005 でビルドできるよう修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 3月 19日 (金) 00:27:26 JST


Revision: 9201
          https://osdn.net/projects/ttssh2/scm/svn/commits/9201
Author:   zmatsuo
Date:     2021-03-19 00:27:25 +0900 (Fri, 19 Mar 2021)
Log Message:
-----------
VS2005 でビルドできるよう修正

- comportinfo.cpp で devpkey.h を利用するようにした
  - VS2005 + SDK7.1 のとき
  - VS2019 のとき
  - MinGW のとき
- VS2005 + SDK7.0 のときはファイルがないので include できない

Modified Paths:
--------------
    trunk/teraterm/common/comportinfo.cpp
    trunk/teraterm/common/devpkey_teraterm.h
    trunk/teraterm/ttpcmn/ttcmn_cominfo.c

-------------- next part --------------
Modified: trunk/teraterm/common/comportinfo.cpp
===================================================================
--- trunk/teraterm/common/comportinfo.cpp	2021-03-18 15:27:14 UTC (rev 9200)
+++ trunk/teraterm/common/comportinfo.cpp	2021-03-18 15:27:25 UTC (rev 9201)
@@ -34,12 +34,48 @@
 #include <crtdbg.h>
 #include <assert.h>
 
-#include "devpkey_teraterm.h"
 #include "ttlib.h"
 #include "codeconv.h"
 
 #include "comportinfo.h"
 
+/*
+ *	devpkey.h \x82\xAA\x82\xA0\x82\xE9\x8A‹\xAB?
+ *		HAS_DEVPKEY_H \x82\xAA define \x82\xB3\x82\xEA\x82\xE9
+ */
+#if	(_MSC_VER > 1400) || defined(__MINGW32__)
+
+// VS2019\x82̂Ƃ\xAB(VS2005\x82\xE6\x82\xE8\x91傫\x82\xA2\x82Ƃ\xB5\x82Ă\xA2\x82\xE9)
+// MinGW(32&64bit)\x82̂Ƃ\xAB
+#define HAS_DEVPKEY_H	1
+
+#else // _MSC_VER > 1400
+
+// VS2008\x82̂Ƃ\xAB
+#if defined(_INC_SDKDDKVER)
+
+// VS2008 + SDK 7.0\x82ł͂Ȃ\xA2\x82Ƃ\xAB(SDK 7.1\x82̂Ƃ\xAB)
+//   SDK 7.0 \x82̏ꍇ\x82\xCD sdkddkver.h \x82\xAA include \x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2
+#define HAS_DEVPKEY_H	1
+
+#endif  //  defined(_INC_SDKDDKVER)
+#endif  // _MSC_VER == 1400
+
+/*
+ *	devpkey.h \x82\xCC include
+ */
+#if defined(HAS_DEVPKEY_H)
+
+#define INITGUID
+#include "devpkey.h"
+
+#else //  defined(HAS_DEVPKEY_H)
+
+#include "devpkey_teraterm.h"
+
+#endif //  defined(HAS_DEVPKEY_H)
+
+
 typedef BOOL (WINAPI *TSetupDiGetDevicePropertyW)(
 	HDEVINFO DeviceInfoSet,
 	PSP_DEVINFO_DATA DeviceInfoData,
@@ -431,6 +467,11 @@
  */
 ComPortInfo_t *ComPortInfoGet(int *count, const char *lang)
 {
+#if defined(_MSC_VER) && _MSC_VER > 1400
+	// VS2005\x82\xE6\x82肠\x82\xBD\x82炵\x82\xA2\x8Fꍇ\x82\xCD 9x \x82ŋN\x93\xAE\x82\xB5\x82Ȃ\xA2\x83o\x83C\x83i\x83\x8A\x82ƂȂ\xE9
+	const bool is_setupapi_supported = true;
+#else
+	// VS2005 or MinGW
 	OSVERSIONINFOA osvi;
 	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 	GetVersionExA(&osvi);
@@ -443,6 +484,7 @@
 		// Windows NT4.0
 		is_setupapi_supported = false;
 	}
+#endif
 
 	if (is_setupapi_supported) {
 		return ComPortInfoGetByGetSetupAPI(count);

Modified: trunk/teraterm/common/devpkey_teraterm.h
===================================================================
--- trunk/teraterm/common/devpkey_teraterm.h	2021-03-18 15:27:14 UTC (rev 9200)
+++ trunk/teraterm/common/devpkey_teraterm.h	2021-03-18 15:27:25 UTC (rev 9201)
@@ -28,12 +28,14 @@
 
 #pragma once
 
-/*
- * Visual Studio 2005\x82Ńr\x83\x8B\x83h\x82\xF0\x92ʂ\xB7\x82\xBD\x82߂ɂ͉\xBA\x8BL\x82̒\xE8\x8B`\x82\xAA\x95K\x97v\x81B
- * Visual Studio 2019\x82ł͕s\x97v\x81B
- */
-#if _MSC_VER == 1400 && !defined(DEVPROPKEY_DEFINED)
+// \x82\xB1\x82̃t\x83@\x83C\x83\x8B\x82\xCDVS2005\x82̎\x9E\x82\xBE\x82\xAF\x8EQ\x8FƂ\xB3\x82\xEA\x82\xE9
+#if defined(__MINGW32__) || _MSC_VER != 1400
+#error check file dependency
+#endif
+
 typedef ULONG DEVPROPTYPE, *PDEVPROPTYPE;
+#define DEVPROP_TYPE_FILETIME                   0x00000010  // file time (FILETIME)
+#define DEVPROP_TYPE_STRING                     0x00000012  // null-terminated string
 
 typedef GUID  DEVPROPGUID, *PDEVPROPGUID;
 typedef ULONG DEVPROPID,   *PDEVPROPID;
@@ -42,9 +44,8 @@
     DEVPROPGUID fmtid;
     DEVPROPID   pid;
 } DEVPROPKEY, *PDEVPROPKEY;
-#endif
 
-#undef DEFINE_DEVPROPKEY
+
 #define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }, pid }
 
 /*
@@ -57,4 +58,3 @@
 DEFINE_DEVPROPKEY(DEVPKEY_Device_DriverProvider,           0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 9);     // DEVPROP_TYPE_STRING
 DEFINE_DEVPROPKEY(DEVPKEY_Device_DriverDate,               0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 2);     // DEVPROP_TYPE_FILETIME
 DEFINE_DEVPROPKEY(DEVPKEY_Device_DriverVersion,            0xa8b865dd, 0x2e3d, 0x4094, 0xad, 0x97, 0xe5, 0x93, 0xa7, 0xc, 0x75, 0xd6, 3);     // DEVPROP_TYPE_STRING
-

Modified: trunk/teraterm/ttpcmn/ttcmn_cominfo.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn_cominfo.c	2021-03-18 15:27:14 UTC (rev 9200)
+++ trunk/teraterm/ttpcmn/ttcmn_cominfo.c	2021-03-18 15:27:25 UTC (rev 9201)
@@ -52,6 +52,8 @@
 {
 	int count;
 	int i;
+	ComPortInfo_t *port_info;
+	const ComPortInfo_t *p;
 
 	// \x88ȑO\x8Am\x95ۂ\xB5\x82\xBD\x95\xAA\x82\xF0\x8AJ\x95\xFA\x82\xB7\x82\xE9
 	for (i = 0; i < ComPortMax; i++) {
@@ -59,8 +61,8 @@
 		ComPortDesc[i] = NULL;
 	}
 
-	ComPortInfo_t *port_info = ComPortInfoGet(&count, NULL);
-	const ComPortInfo_t *p = port_info;
+	port_info = ComPortInfoGet(&count, NULL);
+	p = port_info;
 	for (i = 0; i < count; i++) {
 		ComPortTable[i] = p->port_no;
 		ComPortDesc[i] = ToCharW(p->friendly_name);


Ttssh2-commit メーリングリストの案内
Back to archive index