473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using XP's CD writing support

Bob
Hi there,

Can anyone point me to anything relating to using XP's built-in CD writing
support from VB.Net... or even C#, or classic VB...?

I just want to write files to the CD and finalise the session and disk.

Cheers
Nov 20 '05 #1
10 2071
* "Bob" <bo*@nospam.com > scripsit:
Can anyone point me to anything relating to using XP's built-in CD writing
support from VB.Net... or even C#, or classic VB...?

I just want to write files to the CD and finalise the session and disk.


C++ + IMAPI:

<http://www.gotdotnet.c om/team/cplusplus/samples/cd%20burning.zi p>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Bob
Herfried,

Thanks for the info... I'll check it out but I'd rather see something using
the other .Net languages... I don't see why it wouldn't be possible..?

Cheers
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:bn******** *****@ID-208219.news.uni-berlin.de...
* "Bob" <bo*@nospam.com > scripsit:
Can anyone point me to anything relating to using XP's built-in CD writing support from VB.Net... or even C#, or classic VB...?

I just want to write files to the CD and finalise the session and disk.


C++ + IMAPI:

<http://www.gotdotnet.c om/team/cplusplus/samples/cd%20burning.zi p>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
Hi Bob,

You are going to have to define the interface yourself in code, and then
find the GUID of the co class that implements it. Once you have that, you
can use the methods on the Marshal class and Activator class to create your
instance and get a wrapper of the appropriate type (using CreateInstance
and CreateWrapperOf Type).

http://groups.google.com/groups?hl=e...readm=90079f6d
0204020218.42bf f604%40posting. google.com&rnum =1&prev=/groups%3Fhl%3De n%26lr
%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dxp%2Bcd %2Bburning%2B%2 522c%2523%2522% 26s
a%3DN%26tab%3Dw g

http://www.microsoft.com/seminar/sha...nar/en/2002091
8devt1-63/manifest.xml
slide 59 has what customer is trying to figure out.

If you have any related question please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
This response contains a reference to a third-party World Wide Web site.
Microsoft is providing this information as a convenience to you. Microsoft
does not control these sites and has not tested any software or information
found on these sites; therefore, Microsoft cannot make any representations
regarding the quality, safety, or suitability of any software or
information found there. There are inherent dangers in the use of any
software found on the Internet, and Microsoft cautions you to make sure
that you completely understand the risk before retrieving any software from
the Internet.

Nov 20 '05 #4
Bob
Hmmm...

Looks like a lot of work to do something fairly simple... I was thinking
more along the lines of copying the files to the CD drive and then calling
the Write Files option in the context menu (when right clicking on the
cd-writer) programatically ... why reinvent the wheel...

Feasible?

Cheers
"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:pq******** ******@cpmsftng xa06.phx.gbl...
Hi Bob,

You are going to have to define the interface yourself in code, and then
find the GUID of the co class that implements it. Once you have that, you
can use the methods on the Marshal class and Activator class to create your instance and get a wrapper of the appropriate type (using CreateInstance
and CreateWrapperOf Type).

http://groups.google.com/groups?hl=e...readm=90079f6d 0204020218.42bf f604%40posting. google.com&rnum =1&prev=/groups%3Fhl%3De n%26lr %3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dxp%2Bcd %2Bburning%2B%2 522c%2523%2522% 26s a%3DN%26tab%3Dw g

http://www.microsoft.com/seminar/sha...nar/en/2002091 8devt1-63/manifest.xml
slide 59 has what customer is trying to figure out.

If you have any related question please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
This response contains a reference to a third-party World Wide Web site.
Microsoft is providing this information as a convenience to you. Microsoft
does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations
regarding the quality, safety, or suitability of any software or
information found there. There are inherent dangers in the use of any
software found on the Internet, and Microsoft cautions you to make sure
that you completely understand the risk before retrieving any software from the Internet.

Nov 20 '05 #5
Hi Bob,

Another way is to convert the C++ sample into an COM object so that you can
call it from .NET.

Otherwise, you should do as I posted in last post, that is to say you may
need to implement the least interface needed to complete your task, because
the IMAPI is a set of APIs.

Interacting with IMAPI
http://msdn.microsoft.com/library/de...us/devio/base/
interacting_wit h_imapi.asp
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #6
Bob
Yeah ok... still a bit stuck on that one... can you repost the google link
as it didn't seem to work... even when I fixed line breaks etc...

Not familiar enough with C++ to be converting it to anything. And I am not
sure how to declare and use the IMAPI API within VB.Net...

I'll see how I go with what you have suggested though...

Cheers
"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:fT******** ******@cpmsftng xa06.phx.gbl...
Hi Bob,

Another way is to convert the C++ sample into an COM object so that you can call it from .NET.

Otherwise, you should do as I posted in last post, that is to say you may
need to implement the least interface needed to complete your task, because the IMAPI is a set of APIs.

Interacting with IMAPI
http://msdn.microsoft.com/library/de...us/devio/base/ interacting_wit h_imapi.asp
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #7
Hi Bob,

You may try to search the key words below in the website groups.google.c om
"Mark Bonner" "perform CD"

I re-search it and get a result as follows.
http://groups.google.com/groups?q=%2...+CD%22&hl=en&l
r=&ie=UTF-8&oe=UTF-8&selm=u1CIWzk2 BHA.1984%40tkms ftngp02&rnum=1

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #8
Bob
Ok, I had a read but it sounds like way too much crap to deal with to do
something so simple. I really am disappointed that the .Net framework has
left out so many basic things... seems that all the power that has been
added doesn't make up for the lack of basic functionality.

Anyway, I realised a while back that .Net wasn't going to deliver everything
it was claimed to. I am trying hard to introduce .Net to the organisation I
am working for (major Unix/Java/Oracle shop) but so far .Net can't really
deliver what they have asked for (working with GINA, CD writing etc). If
these guys decide to dump .Net I'm outta here and that looks like the way
they'll go if simple things like this prove to be this difficult.

In case you ask - they want to avoid C++ as much as I do. So no, I can't get
it done all in C++ - and even if I did, what does that say about the rest of
..Net... might as well stick to a language from the 70's......?????

Are you sure there is no way I can simply call the "Write files" option in
the context menu of the CD/RW drive in Explorer?

Cheers

"Peter Huang" <v-******@online.m icrosoft.com> wrote in message
news:Z3******** ******@cpmsftng xa06.phx.gbl...
Hi Bob,

You may try to search the key words below in the website groups.google.c om
"Mark Bonner" "perform CD"

I re-search it and get a result as follows.
http://groups.google.com/groups?q=%2...+CD%22&hl=en&l r=&ie=UTF-8&oe=UTF-8&selm=u1CIWzk2 BHA.1984%40tkms ftngp02&rnum=1

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #9
Hello Bob,

I just reviewed the whole post thread. In fact, this is a FAQ in .NET
programming. Many developers may feel confused where to find corresponding
..NET framework class libraries in programming. In fact, all the framwork
class library could be found at:
http://msdn.microsoft.com/library/en....asp?frame=tru
e

However, .NET framework class library doesn't build in all Win32 SDK APIs
or functions. That is to say, for some Win32 functions, such as GINA,
setting default printer, burning CD, we still need to use typical Win32 API
to achieve it. In order to do so in .NET programming, we provide a method
named Platform Invoke to call typical Win32 APIs in .NET application. For
more information on PInvoke, please refer to:
http://msdn.microsoft.com/library/en...roperatingwith
unmanagedcode.a sp?frame=true

For this question, currently we have no famework class library support for
burning CD. My suggestion for you is to write a win32 DLL to expose
funtions that you need. You could select whatever languages you like to
develop this Win32 DLL, VC++ or VB. After that, we could call this
unmanaged DLL functions from managed .NET application easily. Peter Huang
has provided an existing sample to you. I also post some useful code slice
in the end of this post. You could refer to it.

There is currently no way to do this, but keep an eye out for it in the
future. We are looking at continual improvement, and it's this kind of
feedback that let us know what things you're trying to do, that we haven't
yet exposed for you.

Keep the information coming.

Thanks very much for your understanding.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Code Slice:

Below is a simple Imapi sample that works for me. I made a console "Hello
world" project and replaced it with the code below. IT takes a command
line path of a driectory to copy, and I added the string: "e:\\CDBurn.exe "
as a known file that would be in the result.

This works for me.

// cd.cpp : Defines the entry point for the console application. //

#include "stdafx.h"

#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <objbase.h>
#include <stdio.h>
#include <shlobj.h>
#include "imapi.h"

HRESULT GetStorage(LPWS TR pszDir, IStorage **ppstg)
{
IShellFolder *psfDesktop;
HRESULT hr = SHGetDesktopFol der(&psfDesktop );
if (SUCCEEDED(hr))
{
IMalloc *pm;
hr = SHGetMalloc(&pm );
if (SUCCEEDED(hr))
{
LPITEMIDLIST pidl;
hr = psfDesktop->ParseDisplayNa me(NULL, NULL, pszDir, NULL,
&pidl,
NULL);
if (SUCCEEDED(hr))
{
hr = psfDesktop->BindToObject(p idl, NULL, IID_IStorage,
(void**)ppstg);
pm->Free(pidl);
}
pm->Release();
}
psfDesktop->Release();
}
return hr;
}

HRESULT SetUpRecorder(I DiscMaster *pdm, IJolietDiscMast er *pjdm, LPWSTR
pszDir) {
wprintf(L"Getti ng recorder enumerator object.\n");

IEnumDiscRecord ers *pedr;
HRESULT hr = pdm->EnumDiscRecord ers(&pedr);
if (SUCCEEDED(hr))
{
wprintf(L"Findi ng available drive.\n");

ULONG celt;
IDiscRecorder *pdr;
// pick the first supported drive to write to.
hr = pedr->Next(1, &pdr, &celt);
if (S_OK == hr)
{
wprintf(L"Setti ng active disc recorder.\n");

hr = pdm->SetActiveDiscR ecorder(pdr);
if (SUCCEEDED(hr))
{
IStorage *pstg;
hr = GetStorage(pszD ir, &pstg);
if (SUCCEEDED(hr))
{
wprintf(L"Addin g data to stash file.\n");
hr = pjdm->AddData(pstg , 1);
pstg->Release();
}
else
{
wprintf(L"Could n't get storage, please check the
path.\n");
}
}
pdr->Release();
}
else
{
wprintf(L"No supported drives found, HRESULT = 0x%08X\n", hr);
hr = E_FAIL;
}
pedr->Release();
}
return hr;
}

void DoBurn(LPWSTR pszDir)
{
wprintf(L"Burni ng directory %s.\n", pszDir);

wprintf(L"CoCre ating object.\n");
IDiscMaster *pdm;
HRESULT hr = CoCreateInstanc e(CLSID_MSDiscM asterObj, NULL, CLSCTX_ALL,
IID_IDiscMaster , (void**)&pdm);
if (SUCCEEDED(hr))
{
wprintf(L"Initi alizing.\n");

hr = pdm->Open();
if (SUCCEEDED(hr))
{
wprintf(L"Setti ng active disc master format to Joliet.\n");

IJolietDiscMast er *pjdm;
hr = pdm->SetActiveDiscM asterFormat(IID _IJolietDiscMas ter,
(void**)&pjdm);
if (SUCCEEDED(hr))
{
hr = SetUpRecorder(p dm, pjdm, pszDir);
if (SUCCEEDED(hr))
{
wprintf(L"Burni ng disc.\n");
// first param FALSE for non-simulated burn.
// second param TRUE to eject on completion.
hr = pdm->RecordDisc(FAL SE, TRUE);
}
// Get IDiscRecorder and close;
IDiscRecorder* piDR;
pdm->GetActiveDiscR ecorder(&piDR);
piDR->Close();

pjdm->Release();
}
}
pdm->Release();
}

if (SUCCEEDED(hr))
{
wprintf(L"Burni ng succeeded.\n");
}
else
{
wprintf(L"Failu re, HRESULT = 0x%08X\n", hr);
}
}

int __cdecl wmain(int argc, WCHAR *argv[])
{
if (argc != 2)
{
wprintf(L"IMAPI demo\nUsage: %s <directory to burn>\nExample: \"%s
c:\\files\"\n", argv[0], argv[0]);
}
else
{
if (SUCCEEDED(CoIn itializeEx(NULL , COINIT_APARTMEN TTHREADED)))
{
DoBurn(argv[1]);
//=============== =============== =============== =============== =======
//detect if the burn operation worked:
WIN32_FIND_DATA data;
HRESULT hr;
HANDLE hFind = FindFirstFile(( LPCTSTR)"e:\\CD Burn.exe", &data);
if (hFind == INVALID_HANDLE_ VALUE)
{
printf("RecordD isc did not return error but no files were burned");
hr = HRESULT_FROM_WI N32(ERROR_FILE_ NOT_FOUND); //<====it always
comes
here
}
else
{
FindClose(hFind );
hr = S_OK;
} //=============== =============== =============== =============== =======
CoUninitialize( );
}
}
return 0;
}

Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9845
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out | ios::binary) to declare a file object with read/write modes turned on for working with binary data. I've tried this and my file is not created. The only time it is created is when I specify ifstream or ofstream but not fstream. I've tried removing the...
3
2885
by: Chris Williamson | last post by:
Hi, Currently I am working on a Visual Basic program that makes use of an Access database produced under Japanese Access '97. The program works correctly on Windows 2000, however when it is used under English XP, Visual Basic reports the error "Could not find file" when it tries to open the database. I have tried converting the database to Access 2000, however this now
1
4164
by: Norman Fritag | last post by:
Hi there I have avoided to use active x controls because I thought they are causing more problems then they are doing any good. I a new application I would want to use the tree and list view control in access 2002. Prior to that I like to fine some information or here some feed back from developers who have use active x controls success fully in there application, what their experience was.
9
3958
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
8
2574
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
7
4302
by: Terry Olsen | last post by:
I paste the following code into each project to get XP theme support. 'Add this at the beginning of any program to enable Windows XP Visual Styles <System.STAThread()> Public Shared Sub Main() If OSFeature.Feature.IsPresent(OSFeature.Themes) Then System.Windows.Forms.Application.EnableVisualStyles() End If Application.DoEvents() 'This must be here, otherwise buttons won't stylize System.Windows.Forms.Application.Run(New Form1) End Sub...
4
8826
by: Steve Barker | last post by:
Hi guys! I have written a .NET application that uses WMI to iterate through CD drives, in order to detect whether a certain CD has been loaded into the CD Drive. When the application starts up, I run a basic WMI query to check whether WMI is installed. Clearly, there are some issues with older versions of Windows not having WMI
2
1921
by: Jeff Gaines | last post by:
I am in the process of upgrading to XP 64. VS2008 is running fine but one of my apps, which adds functionality to the Explorer context menu, just won't work under XP 64. Googling resulted in my finding an article saying that MSFT recommends against writing shell extensions in managed code and does not consider them a supported scenario. So, can anybody point me to any articles relating to writing shell extensions in non managed code...
13
3990
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.aspnet&mid=e9a38d03-83a8-41fc-8950-5ee60d2a18a5. I have a web site under .NET 2.0 that renders videos using the Silverlight media player. When I stream the video file (.wmv) to the browser via a hard-coded link to the file,...
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.