{"id":4083,"date":"2010-02-02T14:12:00","date_gmt":"2010-02-02T14:12:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2010\/02\/02\/atl-support-for-transaction-file-system\/"},"modified":"2019-02-18T18:45:40","modified_gmt":"2019-02-18T18:45:40","slug":"atl-support-for-transaction-file-system","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/atl-support-for-transaction-file-system\/","title":{"rendered":"ATL support for Transaction File System"},"content":{"rendered":"<p class=\"MsoNormal\"><span>Hello,<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>My name is Weidong Huang, and I am an SDET on the Visual C++ team. Today, I would like to talk a little about ATL support for Transaction File System in Visual Studio 2010.<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>What is Transactional File System?<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Transactional File System is a new technology first introduced in Windows Vista. It enables you to roll back operations made on the file system and registry.&nbsp; It is helpful in improving application reliability and data consistency without having to add your own tooling.&nbsp; By using transactional file systems in VC++ you can treat a set of operations to files and registry as a transaction which can either be completed as a whole or reversed. <\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>One example that could use Transactional File System:&nbsp; A developer creates several new files, writes some information into them, deletes one existing file and wishes to either complete all the operations or do nothing at all.&nbsp; He could use the Transactional File System to create a transaction, add all the steps into this transaction,&nbsp;commit it when everything works fine, or rollback if there is anything wrong with a step.&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>What is implemented in Visual Studio 2010?<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoListParagraph\">\n<p><font face=\"Times New Roman\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">1.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Added a new ATL class &ldquo;CAtlTransactionalManager&rdquo;:&nbsp; CAtlTransactionManager is a new class wrapping Transaction File System Windows APIs and provides most of Transactional File System functionalities that are implemented in VC++, including: <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\"><font face=\"Times New Roman\">File Operations: CreateFile, DeleteFile, FindFirstFile, GetFileAttributes, SetFileAttributes, MoveFile.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\"><font face=\"Times New Roman\">Registry Operations: RegCreateKeyEx, RegDeleteKey, RegOpenKeyEx<\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\"><\/p>\n<p><\/font><\/font>&nbsp;<\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">2.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Added transaction support to Existing Classes and APIs, including:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\"><font face=\"Times New Roman\">Classes: CFile, CStdioFile, CAtlFile, CFileFind by adding a constructor with TransactionManager as following format: <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\">CFile(CAtlTransactionManager *);<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\">CStdioFile(CAtlTransactionManager *);<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\">CAtlFile(CAtlTransactionManager *);<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\">CFileFind(CAtlTransactionManager *);<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><span><span><font size=\"3\">&middot;<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\"><font face=\"Times New Roman\">APIs: AfxRegCreateKey, AfxRegOpenKey, AfxRegDeleteKey by adding a parameter TransactionManager to the API.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\">\n<p><font face=\"Times New Roman\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoNormal\"><b><span>How to use Transaction File System?<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">1.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">With CAtlTransactionManager:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(1)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create a CAtlTransactionManager;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(2)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call functions in CAtlTransationManager to do operations on File or registry <\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(3)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call Transaction Manager Commit() to submit the change or RollBack() to reverse the change.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><font size=\"3\"><b><span>Note: <\/span><\/b><span>Please refer to Walkthrough Step 2, 3, 4 and 5 for code example. <\/p>\n<p><\/span><\/font><\/p>\n<p class=\"MsoNormal\">\n<p><font face=\"Calibri\" size=\"3\">&nbsp;<\/font><\/p>\n<\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">2.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">With CFile, CStdioFile, CAtlFile, CFileFind:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(1)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create a CAtlTransactionManager;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(2)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create class with the Transaction Manager created in the first step;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(3)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call class member functions to do operations on File;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(4)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call Transaction Manager Commit() to submit the change or RollBack() to reverse the change.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font size=\"3\"><font face=\"Times New Roman\"><b>Note: <\/b>Please refer to Walkthrough Step6 for code example.<b><\/p>\n<p><\/b><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">3.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">With Registry APIs:<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(1)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create a CAtlTransactionManager;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(2)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call API functions with the Transaction Manager created in the first step to do operations on File;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(3)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Call Transaction Manager Commit() to submit the change or RollBack() to reverse the change.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><b><span>What will happen in operating systems prior to Windows Vista?<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span>Transactional File System is only supported in Windows Vista or up level OSes and not available&nbsp;on operating systems prior Vista such as Windows XP and Windows 2003.&nbsp; Will the application crash if it uses Transactional System Functionality in an operating system that doesn&rsquo;t support it?&nbsp; The answer is no.&nbsp; When creating CAtlTransactionManager, there is an option called &ldquo;Fallback&rdquo; which is use to control the behavior in operating systems prior to Vista.&nbsp; <span>By default, the fallback is TRUE which means you will get the same behavior just as that of non-transactional version if Transaction File System is not supported.&nbsp; If you set the fallback to FALSE, then the operation will fail when it is not supported.<\/span>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/p>\n<p class=\"MsoNormal\"><b><span>Walkthrough to use Transaction File System:<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span><\/p>\n<p>&nbsp;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><span>Here is the walkthrough to help you understand the usage of Transaction File System: <\/p>\n<p><\/span><\/p>\n<h2><span>Step1: Create project<\/span><\/h2>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">1.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create a default Dialog Type MFC Application call &ldquo;TransactionalFileSystemDemo&rdquo;.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span>2.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Double click the OK button in default dialog (not file dialog) and create the default event handler &ldquo;<\/font><span>void<\/span><span> <\/span><font size=\"3\">CTransactionalFileSystemDemoDlg::OnBnClickedOk()&rdquo;. All codes in following steps will be added to this function.<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<h2><span>Step2: Use CAtlTransactionManager to Commit File Transaction<\/span><\/h2>\n<h2><span><\/p>\n<p><\/span>&nbsp;<\/h2>\n<p class=\"MsoNormal\"><b><span><font size=\"3\">Add codes<\/p>\n<p><\/font><\/span><\/b><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">(1)<\/font><span>&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Add following code to CTransactionalFileSystemDemoDlg::OnBnClickedOk()<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAtlTransactionManager tmFileCommit1;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HANDLE hFile;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hFile = tmFileCommit1.CreateFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file1.txt&#8221;), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseHandle(hFile);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hFile = tmFileCommit1.CreateFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file2.txt&#8221;), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseHandle(hFile);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hFile = tmFileCommit1.CreateFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file3.txt&#8221;), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseHandle(hFile);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WIN32_FIND_DATA nextFile;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmFileCommit1.FindFirstFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file1.txt&#8221;), &amp;nextFile);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmFileCommit1.SetFileAttributes(_T(&#8220;c:\\TransactionFileSystemDemo\\file1.txt&#8221;), FILE_ATTRIBUTE_READONLY);<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DWORD dwAttributes = tmFileCommit1.GetFileAttributes(_T(&#8220;c:\\TransactionFileSystemDemo\\file1.txt&#8221;));<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span>tmFileCommit1.Commit();<\/span><\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>Result<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;nb\nsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAtlTransactionManager tmFileCommit2;<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmFileCommit2.DeleteFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file2.txt&#8221;));<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmFileCommit2.MoveFile(_T(&#8220;c:\\TransactionFileSystemDemo\\file3.txt&#8221;), _T(&#8220;c:\\TransactionFileSystemDemo\\file4.txt&#8221;));<\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span>tmFileCommit2.Commit();<\/span><\/p>\n<p><\/span><\/b><\/p>\n<p class=\"MsoNormal\"><b><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmFileCommit2.Close();<\/span><\/b><span><\/p>\n<p><\/span><\/p>\n<h2><span>Experience:<\/span><\/h2>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">1.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Create new folder &ldquo;c:\\TransactionFileSystemDemo&rdquo;;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">2.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Build the project, set break point at &ldquo;tmFileCommit1.Commit()&rdquo; and &ldquo;tmFileCommit2.Commit()&rdquo;.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">3.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Debug the application, click the default &ldquo;OK&rdquo; button and stop at the first break point;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">a.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Watch the value of nextFile and dwAttributes, they should have expected values.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">b.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Open Explorer and check folder &ldquo;c:\\TransactionFileSystemDemo&rdquo;: no file should be created.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">4.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Continue debug and go one more step, stop just after &ldquo;tmFileCommit1.Commit()&rdquo;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">a.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Check folder &ldquo;c:\\TransactionFileSystemDemo&rdquo;: file1.txt, file2.txt and file3.txt should be created in this folder.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">5.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Continue debug and stop at the second break point;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">a.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Check folder &ldquo;c:\\TransactionFileSystemDemo&rdquo;: file1.txt, file2.txt and file3.txt are still there.<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span><font size=\"3\">6.<\/font><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Continue debug and go one more step, stop just after &ldquo;tmFileCommit1.Commit()&rdquo;<\/p>\n<p><\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><span><span>a.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span><font size=\"3\">Check folder &ldquo;c:\\TransactionFileSystemDemo&rdquo;: file1.txt should be deleted and file3.txt should be renamed to file4.txt.<\/font><\/font><\/p>\n<p class=\"MsoListParagraph\"><font face=\"Times New Roman\"><font size=\"3\"><span><\/p>\n<p><\/span><\/font><\/font><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello, &nbsp; My name is Weidong Huang, and I am an SDET on the Visual C++ team. Today, I would like to talk a little about ATL support for Transaction File System in Visual Studio 2010. &nbsp; What is Transactional File System? &nbsp; Transactional File System is a new technology first introduced in Windows Vista. [&hellip;]<\/p>\n","protected":false},"author":289,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4083","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>Hello, &nbsp; My name is Weidong Huang, and I am an SDET on the Visual C++ team. Today, I would like to talk a little about ATL support for Transaction File System in Visual Studio 2010. &nbsp; What is Transactional File System? &nbsp; Transactional File System is a new technology first introduced in Windows Vista. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/4083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/289"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=4083"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/4083\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=4083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=4083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=4083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}