Skip to content

Commit 4e03ba1

Browse files
author
U-NVIDIA.COM\sahils
committed
Containment assignemnt done
1 parent be1c916 commit 4e03ba1

File tree

50 files changed

+1370
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1370
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
#define UNICODE
2+
#include <Windows.h>
3+
#include<process.h>
4+
5+
#include "..\ContainmentOuterComponentWithRegFile\HeaderForClientOfContainmentComponentWithRegFile.h"
6+
//function declarations
7+
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
8+
//global variables
9+
ISum *pISum = NULL;
10+
ISubtract *pISubtract = NULL;
11+
IMultiplication *pIMultiplication = NULL;
12+
IDivision *pIDivision = NULL;
13+
14+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
15+
{
16+
WNDCLASSEX wndclass;
17+
HWND hwnd;
18+
MSG msg;
19+
TCHAR AppName[] = TEXT("ComClient");
20+
HRESULT hr;
21+
22+
hr = CoInitialize(NULL);
23+
if (FAILED(hr))
24+
{
25+
MessageBox(NULL, TEXT("COM Library Cannot be initilized.\nProgram will now exit."), TEXT("Error"), MB_OK);
26+
exit(0);
27+
}
28+
29+
wndclass.cbSize = sizeof(wndclass);
30+
wndclass.style = CS_HREDRAW | CS_VREDRAW;
31+
wndclass.cbClsExtra = 0;
32+
wndclass.cbWndExtra = 0;
33+
wndclass.lpfnWndProc = WndProc;
34+
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
35+
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
36+
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
37+
wndclass.hInstance = hInstance;
38+
wndclass.lpszClassName = AppName;
39+
wndclass.lpszMenuName = NULL;
40+
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
41+
42+
if (!RegisterClassEx(&wndclass))
43+
{
44+
MessageBox(NULL, TEXT("RegisterClassEx() error"), TEXT("Error"), MB_OK);
45+
exit(0);
46+
}
47+
48+
hwnd = CreateWindow(AppName, TEXT("Client of COM Dll Server"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
49+
50+
ShowWindow(hwnd, nCmdShow);
51+
UpdateWindow(hwnd);
52+
53+
//message loop
54+
while (GetMessage(&msg, NULL, 0, 0))
55+
{
56+
TranslateMessage(&msg);
57+
DispatchMessage(&msg);
58+
}
59+
60+
CoUninitialize();
61+
return (int)msg.wParam;
62+
63+
}
64+
65+
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
66+
{
67+
//function declaration
68+
void SafeInterfaceRelease();
69+
70+
//variable declarations
71+
HRESULT hr;
72+
int iNum1, iNum2, iSum, iSubtraction, iMultiplication, iDivision;
73+
TCHAR str[255];
74+
75+
switch (iMsg)
76+
{
77+
case WM_CREATE:
78+
{
79+
hr = CoCreateInstance(CLSID_SumSubtract, NULL, CLSCTX_INPROC_SERVER, IID_ISum, (void**)&pISum);
80+
if (FAILED(hr))
81+
{
82+
MessageBox(NULL, TEXT("ISum interface cannot be obtained"), TEXT("Error"), MB_OK);
83+
DestroyWindow(hwnd);
84+
break;
85+
}
86+
87+
iNum1 = 65;
88+
iNum2 = 45;
89+
pISum->SumOfTwoIntegers(iNum1, iNum2, &iSum);
90+
wsprintf(str, TEXT("Sum of %d, and %d = %d"), iNum1, iNum2, iSum);
91+
MessageBox(hwnd, str, TEXT("Result"), MB_OK);
92+
hr = pISum->QueryInterface(IID_ISubtract, (void **)&pISubtract);
93+
if (FAILED(hr))
94+
{
95+
MessageBox(hwnd, TEXT("ISubtract interface cannot be obtained"), TEXT("Error"), MB_OK);
96+
DestroyWindow(hwnd);
97+
break;
98+
}
99+
100+
pISum->Release();
101+
pISum = NULL;
102+
103+
iNum1 = 155;
104+
iNum2 = 55;
105+
106+
pISubtract->SubtractionOfTwoIntegers(iNum1, iNum2, &iSubtraction);
107+
wsprintf(str, TEXT("Subtraction of %d, and %d = %d"), iNum1, iNum2, iSubtraction);
108+
MessageBox(hwnd, str, TEXT("Result"), MB_OK);
109+
pISubtract->QueryInterface(IID_IMultiplication, (void**)&pIMultiplication);
110+
if (FAILED(hr))
111+
{
112+
MessageBox(hwnd, TEXT("IMultiplication interface cannot be obtained"), TEXT("Error"), MB_OK);
113+
DestroyWindow(hwnd);
114+
break;
115+
}
116+
117+
pISubtract->Release();
118+
pISubtract = NULL;
119+
120+
iNum1 = 30;
121+
iNum2 = 25;
122+
pIMultiplication->MultiplicationOfTwoIntegers(iNum1, iNum2, &iMultiplication);
123+
wsprintf(str, TEXT("Multiplication of %d, and %d = %d"), iNum1, iNum2, iMultiplication);
124+
MessageBox(hwnd, str, TEXT("Result"), MB_OK);
125+
126+
hr = pIMultiplication->QueryInterface(IID_IDivision, (void**)&pIDivision);
127+
if (FAILED(hr))
128+
{
129+
MessageBox(hwnd, TEXT("IDivision interface cannot be obtained"), TEXT("Error"), MB_OK);
130+
DestroyWindow(hwnd);
131+
break;
132+
}
133+
134+
pIMultiplication->Release();
135+
pIMultiplication = NULL;
136+
137+
iNum1 = 200;
138+
iNum2 = 25;
139+
pIDivision->DivisionOfTwoIntegers(iNum1, iNum2, &iDivision);
140+
141+
wsprintf(str, TEXT("Division of %d, and %d = %d"), iNum1, iNum2, iDivision);
142+
MessageBox(hwnd, str, TEXT("Result"), MB_OK);
143+
144+
pIDivision->Release();
145+
pIDivision = NULL;
146+
DestroyWindow(hwnd);
147+
}
148+
break;
149+
case WM_DESTROY:
150+
{
151+
SafeInterfaceRelease();
152+
PostQuitMessage(0);
153+
}
154+
break;
155+
default:
156+
break;
157+
}
158+
159+
return DefWindowProc(hwnd, iMsg, wParam, lParam);
160+
}
161+
162+
void SafeInterfaceRelease()
163+
{
164+
if (pISum)
165+
{
166+
pISum->Release();
167+
pISum = NULL;
168+
}
169+
if (pISubtract)
170+
{
171+
pISubtract->Release();
172+
pISubtract = NULL;
173+
}
174+
if (pIMultiplication)
175+
{
176+
pIMultiplication->Release();
177+
pIMultiplication = NULL;
178+
}
179+
if (pIDivision)
180+
{
181+
pIDivision->Release();
182+
pIDivision = NULL;
183+
}
184+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#pragma once
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{64DA55EF-AAC5-497D-B3FF-537223B02056}</ProjectGuid>
24+
<RootNamespace>ClientOfContainmentComponentWithRegFile</RootNamespace>
25+
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
26+
</PropertyGroup>
27+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29+
<ConfigurationType>Application</ConfigurationType>
30+
<UseDebugLibraries>true</UseDebugLibraries>
31+
<PlatformToolset>v141</PlatformToolset>
32+
<CharacterSet>MultiByte</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>false</UseDebugLibraries>
37+
<PlatformToolset>v141</PlatformToolset>
38+
<WholeProgramOptimization>true</WholeProgramOptimization>
39+
<CharacterSet>MultiByte</CharacterSet>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42+
<ConfigurationType>Application</ConfigurationType>
43+
<UseDebugLibraries>true</UseDebugLibraries>
44+
<PlatformToolset>v141</PlatformToolset>
45+
<CharacterSet>MultiByte</CharacterSet>
46+
</PropertyGroup>
47+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48+
<ConfigurationType>Application</ConfigurationType>
49+
<UseDebugLibraries>false</UseDebugLibraries>
50+
<PlatformToolset>v141</PlatformToolset>
51+
<WholeProgramOptimization>true</WholeProgramOptimization>
52+
<CharacterSet>MultiByte</CharacterSet>
53+
</PropertyGroup>
54+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55+
<ImportGroup Label="ExtensionSettings">
56+
</ImportGroup>
57+
<ImportGroup Label="Shared">
58+
</ImportGroup>
59+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61+
</ImportGroup>
62+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+
</ImportGroup>
65+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67+
</ImportGroup>
68+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70+
</ImportGroup>
71+
<PropertyGroup Label="UserMacros" />
72+
<PropertyGroup />
73+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
74+
<ClCompile>
75+
<WarningLevel>Level3</WarningLevel>
76+
<Optimization>Disabled</Optimization>
77+
<SDLCheck>true</SDLCheck>
78+
<ConformanceMode>true</ConformanceMode>
79+
</ClCompile>
80+
</ItemDefinitionGroup>
81+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
82+
<ClCompile>
83+
<WarningLevel>Level3</WarningLevel>
84+
<Optimization>Disabled</Optimization>
85+
<SDLCheck>true</SDLCheck>
86+
<ConformanceMode>true</ConformanceMode>
87+
</ClCompile>
88+
</ItemDefinitionGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<Optimization>MaxSpeed</Optimization>
93+
<FunctionLevelLinking>true</FunctionLevelLinking>
94+
<IntrinsicFunctions>true</IntrinsicFunctions>
95+
<SDLCheck>true</SDLCheck>
96+
<ConformanceMode>true</ConformanceMode>
97+
</ClCompile>
98+
<Link>
99+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
100+
<OptimizeReferences>true</OptimizeReferences>
101+
</Link>
102+
</ItemDefinitionGroup>
103+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
104+
<ClCompile>
105+
<WarningLevel>Level3</WarningLevel>
106+
<Optimization>MaxSpeed</Optimization>
107+
<FunctionLevelLinking>true</FunctionLevelLinking>
108+
<IntrinsicFunctions>true</IntrinsicFunctions>
109+
<SDLCheck>true</SDLCheck>
110+
<ConformanceMode>true</ConformanceMode>
111+
</ClCompile>
112+
<Link>
113+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
114+
<OptimizeReferences>true</OptimizeReferences>
115+
</Link>
116+
</ItemDefinitionGroup>
117+
<ItemGroup>
118+
<ClCompile Include="ClientOfContainmentComponentWithRegFile.cpp" />
119+
</ItemGroup>
120+
<ItemGroup>
121+
<ClInclude Include="ClientOfContainmentComponentWithRegFile.h" />
122+
</ItemGroup>
123+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
124+
<ImportGroup Label="ExtensionTargets">
125+
</ImportGroup>
126+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="ClientOfContainmentComponentWithRegFile.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="ClientOfContainmentComponentWithRegFile.h">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
</ItemGroup>
27+
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17134.0
2+
Debug|x64|C:\Users\sahils\Documents\Visual Studio 2017\Projects\GokhaleSirClassPuneWin32DotNetComWinrt\|
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)