1. In HelloSDK.cpp modify the code following the comment //Get DateTime to:
//Get DateTime TCHAR dateTime[100]; //_stprintf ß Comment this function call out //(dateTime, //_T("Time %02d:%02d:%02d Date [DD/MM/YYY] %02d/%02d/%04d\n"), //st.wHour,st.wMinute,st.wSecond, st.wDay, //st.wMonth, st.wYear //); GetTime(dateTime); <-- Add this _putts(dateTime);
//Get DateTime
TCHAR dateTime[100];
//_stprintf ß Comment this function call out
//(dateTime,
//_T("Time %02d:%02d:%02d Date [DD/MM/YYY] %02d/%02d/%04d\n"),
//st.wHour,st.wMinute,st.wSecond, st.wDay,
//st.wMonth, st.wYear
//);
GetTime(dateTime); <-- Add this
_putts(dateTime);
Listing 16.8: Modifications to HelloSDK.cpp for the DLL
2. At the bottom of stdafx.h add the reference to the DLL’s header file:
#include "../sdkTimeDLL/sdkTimeDLL.h"
Listing 16.9: Modifications to stdafx.h in the application project for the DLL.
3. To include the .dll file as content, right-click on the application project in Solution Explorer: Add—>Existing Item and browse to the Solution’s \Debug directory as discussed in the previous section. Select the .dll file generated by the previous section.
Note: If you change from Debug to Release mode then this inclusion would need to be modified. (Select from the Release directory of the solution.)
4. Right-click on the .dll in Solution Explorer in the application project and set it as content as in Figure 1.5 so that it gets deployed with the application.
Figure 16.5: Setting the DLL as content
5. Add a linkage to the DLL’s .lib file opening the application’s property pages and select Configuration Properties/Linker/Input then select Additional Dependencies on the right. Then click on the down arrow and select as in Figure 16.6:
Figure 16.6: Adding linkage information to a project
6. Then add the linkage as in Figure 1.7 .
Figure 16.7: Adding the DLL .lib linkage to the application
Note: This metadata does not need modification if the projects are changed from Debug to Release mode.
7. Finally, right-click on the application project—>Project Dependencies and set the DLL as a dependency of the application project as in Figure 1.8.
Figure 16.8: Setting the DLL as a dependency of the application
8. Build the application and resolve any issues.
9. To show that the DLL is actually debugged when the app runs in debug mode, as in Figure 1.9, set a breakpoint at the start of the GetTime( ) function, deploy and debug the application.
Figure 16.9: The DLL being debugged when the application runs
NEXT: 16.8 Create an SDK Winforms Hello World application
Click here to provide feedback and input