|
안녕하세요.. 초보 개발자입니다.
문제 해결이 안되어서 이렇게 글을 올립니다. 혹시 아시는 분이 계시다면..
답변좀.. 받고 싶습니다. 몇주째 해결을 못하고 있습니다.
VB에서는 동작이 잘 되고 있습니다. 이것을 C++로 구현을 하려니까 참조 해서 만들어야 한다고 해서..하고 있는데..잘 해결이 안되고 있습니다.
콘솔로...
// stet.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const UINT WM_ONRECEIVE_EVENT = 0x8200; //WM_APP+0x0200
const UINT WM_ONSTATUS_EVENT = 0x8201;
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
const TCHAR * const kpszSignIn = _T("BSIA1234PM/GS");
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
HRESULT hr = S_OK;
//CComPtr<IWSConfiguredDevices> spicd;
WSDeviceType wDevType;
CComBSTR bstr,GRS,Gateway,DeviceDescript,GetAllGCIDDAs,GetAllGCIDDAsX;
hr = CoInitialize(NULL);
if (hr != S_OK){
MessageBox(NULL, "Error on CoInitializeEx", NULL, NULL);
}
CoInitialize(NULL);
IWSConfiguredDevices *spicd;
hr = CoCreateInstance(__uuidof(WSConfiguredDevices), NULL, CLSCTX_ALL, __uuidof(IWSConfiguredDevices), (void**)&spicd);
if (hr != S_OK)
{
printf ( "WSConfiguredDevices 인터페이스를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
// ASSERT_VALID(spicd);
hr = spicd->Register(L"GORES");
if (hr !=S_OK) {
printf ( "Register 메소드를 호출 하지 못했습니다. failed: 0x%x\n", hr);
return false ;
}
IWSDevice* spicds;
hr = CoCreateInstance(__uuidof(WSDevice), NULL, CLSCTX_ALL, __uuidof(IWSDevice), (void**)&spicds);
if (hr != S_OK){
printf ("CLSID_WSDevice 인터페이스를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
spicds->get_DeviceType(&wDevType);
if (hr != S_OK){
printf ("DeviceType 메소드를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
if ((wDevType == DT_DIR) || (wDevType == DT_CRT))
{
CComBSTR bstr ;
hr = spicds->get_Poolname(&bstr);
if (hr != S_OK){
printf ("get_Poolname 메소드를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
printf("SFFF\n");
}
else{
printf("SFFFXX\n");
}
IWSHostSessionDispatch* spicdss;
hr = CoCreateInstance(__uuidof(WSHostSessionDispatch), NULL, CLSCTX_ALL, __uuidof(IWSHostSessionDispatch), (void**)&spicdss);
잘 넘어가다가..
if (hr != S_OK){ <-----여기서 부터는 진행이 안되고 나와 버립니다.
printf ("CLSID_WSHostSessionDispatch 인터페이스를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
hr = spicdss->InitializeEx(L"GO",bstr,0);
if (hr != S_OK){
printf ("Initialize 메소드를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
hr = spicdss->Open();
if (hr != S_OK){
printf ("Open 메소드를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
hr = spicdss->Send((BSTR)kpszSignIn);
if (hr != S_OK){
printf ("Send 메소드를 호출 하지 못했습니다.failed: 0x%x\n", hr);
return false ;
}
::CoUninitialize();
return 0;
}
VB에서 참조 하는 형식..(잘 사용되고 있습니다.)
Dim WithEvents x As WSHostSessionDispatch 'dll 참조
Dim DeviceList As WSConfiguredDevices 'dll 참조
Dim PoolToOpen As String
Dim DeviceToOpen As Long
'''변수.
Private Sub Form_Load()
Dim Device As WSDevice
Set DeviceList = CreateObject("WSClient.WSConfiguredDevices")
Dim Index As Integer
DeviceList.Register "Go"
Index = 0
For Each Device In DeviceList
Text1.text = Device.Poolname, 0
Index = Index + 1
Next
End Sub
Private Sub OpenHostSession_Click()
Dim strGCIDDA As String
Dim locDevice As WSDevice
On Error GoTo 1
Set x = CreateObject("WSClient.WSHostSessionDispatch")
If (OpenByPool = True) And (PoolToOpen <> "") Then
x.InitializeEx "GO", PoolToOpen, 1
End If
If (OpenByPool = False) And (DeviceToOpen <> 0) Then
x.Initialize "GO", DeviceToOpen, 1
End If
x.Open
('''불필요.. 생략...)
Set x = Nothing
End Sub
Private Sub ConvertDeviceString(ByVal strDeviceType As String)
Select Case strDeviceType
Case "NOT_A_DEVICE"
DeviceToOpen = 0
Case "FILE"
DeviceToOpen = 131072
Case "FILE_COMPASS"
DeviceToOpen = 131073
Case "FILE_ITINERARY"
DeviceToOpen = 131074
Case "FILE_INTERFACE_US"
DeviceToOpen = 131075
Case "FILE_INTERFACE_EC"
DeviceToOpen = 131076
Case "CRT"
DeviceToOpen = 262144
Case "DIR"
DeviceToOpen = 262145
Case "DIAG_CRT"
DeviceToOpen = 262146
Case "CURBSIDE"
DeviceToOpen = 1048576
Case "PRINTER"
DeviceToOpen = 2097152
Case "PRINTER_ATB"
DeviceToOpen = 2097153
Case "PRINTER_ATB2"
DeviceToOpen = 2097154
Case "PRINTER_BOARDINGPASS"
DeviceToOpen = 2097156
Case "PRINTER_HARD_COPY"
DeviceToOpen = 2097160
Case "PRINTER_IAB"
DeviceToOpen = 2097168
Case "PRINTER_ITINERARY"
DeviceToOpen = 2097184
Case "PRINTER_TAT"
DeviceToOpen = 2097216
Case "PRINTER_TICKET"
DeviceToOpen = 2097280
Case "PRINTER_MULTI_FUNC"
DeviceToOpen = 2098176
Case "PRINTER_INVOICE"
DeviceToOpen = 2101248
Case "PRINTER_INTERFACE"
DeviceToOpen = 2105344
Case "PRINTER_INTERFACE_CABLE"
DeviceToOpen = 2113536
Case Else
DeviceToOpen = 65535
End Select
End Sub
Private Sub ConvertDeviceType(ByVal lDeviceType As Long)
Select Case lDeviceType
Case 0
DeviceName = "DT_NOT_A_DEVICE"
Case 65535
DeviceName = "DT_UNKNOWN"
Case 131072
DeviceName = "DT_FILE"
Case 131073
DeviceName = "DT_FILE_COMPASS"
Case 131074
DeviceName = "DT_FILE_ITINERARY"
Case 131075
DeviceName = "DT_FILE_INTERFACE_US"
Case 131076
DeviceName = "DT_FILE_INTERFACE_EC"
Case 262144
DeviceName = "DT_CRT"
Case 262145
DeviceName = "DT_DIR"
Case 262146
DeviceName = "DT_DIAG_CRT"
Case 1048576
DeviceName = "DT_CURBSIDE"
Case 2097152
DeviceName = "DT_PRINTER"
Case 2097153
DeviceName = "DT_PRINTER_ATB"
Case 2097154
DeviceName = "DT_PRINTER_ATB2"
Case 2097156
DeviceName = "DT_PRINTER_BOARDINGPASS"
Case 2097160
DeviceName = "DT_PRINTER_HARD_COPY"
Case 2097168
DeviceName = "DT_PRINTER_IAB"
Case 2097184
DeviceName = "DT_PRINTER_ITINERARY"
Case 2097216
DeviceName = "DT_PRINTER_TAT"
Case 2097280
DeviceName = "DT_PRINTER_TICKET"
Case 2098176
DeviceName = "DT_PRINTER_MULTI_FUNC"
Case 2101248
DeviceName = "DT_PRINTER_INVOICE"
Case 2105344
DeviceName = "DT_PRINTER_INTERFACE"
Case 2113536
DeviceName = "DT_PRINTER_INTERFACE_CABLE"
End Select
End Sub
머리가 너무 나뻐서 해결이 잘 안되고 있습니다. 아시는 분 답변 주시면 감사드리겠습니다.
|